48 changed files with 1529 additions and 1558 deletions
@ -1,22 +1,19 @@ |
|||||||
# ECharts类介绍 |
# AbstractECharts类介绍 |
||||||
|
|
||||||
ECharts是`com.fr.chart.chartattr.Chart`的子类,需要实现几个重要的方法 |
### AbstractECharts 继承抽象类AbstractChartWithData,需要实现几个重要的方法 |
||||||
|
|
||||||
两个构造方法,一个为不带参数,一个为带[EChartsPlot](echarts_plot.md)参数 |
//改图表类型对应的ID,同plugin.xml中定义的plotID |
||||||
|
|
||||||
|
`public String getID()` |
||||||
|
|
||||||
// 生成图表配置属性的方法,最终用于生成一个JSON格式的数据到web端 |
// 生成图表配置属性的方法,最终用于生成一个JSON格式的数据到web端 |
||||||
|
|
||||||
`public BaseChartGlyph createGlyph(ChartData chartData) ` |
`public JSONObject createAttributeConfig(ChartWebParaProvider chartWebPara)` |
||||||
|
|
||||||
// 判断能够接收的图表类型 |
// 读取xml中相关配置,基本数据类型可重写readAttr |
||||||
|
|
||||||
`public boolean accept(Class<? extends Chart> obClass)` |
`public void readXML(XMLableReader reader)` |
||||||
|
|
||||||
// 读取xml中相关配置 |
// 各种设置信息保存到xml文件中,基本数据类型可重写readAttr |
||||||
|
|
||||||
`protected void readChartXML(XMLableReader reader)` |
|
||||||
|
|
||||||
// 各种设置信息保存到xml文件中 |
|
||||||
|
|
||||||
`public void writeXML(XMLPrintWriter writer)` |
`public void writeXML(XMLPrintWriter writer)` |
@ -1,61 +1,62 @@ |
|||||||
# ECharts图表插件开发文档 |
# ECharts图表插件开发文档 |
||||||
|
|
||||||
|
## 开发文档 |
||||||
|
[详细开发文档点击这里查看](https://kms.finedevelop.com/pages/viewpage.action?pageId=81570214&focusedCommentId=83937068#comment-83937068) |
||||||
|
|
||||||
## 关键接口解释 |
## 关键接口解释 |
||||||
|
|
||||||
`IndependentChartProvider` |
`ChartTypeProvider` |
||||||
|
|
||||||
介绍:该接口的作用是扩展图表类型引擎部分,一般继承`AbstractIndependentEChartsProvider`就可以了 |
介绍:该接口的作用是扩展图表类型引擎部分,一般继承`AbstractEChartsType`就可以了 |
||||||
|
|
||||||
`IndependentChartUIProvider` |
`ChartTypeUIProvider` |
||||||
|
|
||||||
介绍:该接口的作用是扩展图表类型的设计器部分,一般继承`AbstractIndependentEChartsUI`就可以了 |
介绍:该接口的作用是扩展图表类型的设计器部分,一般继承`AbstractEChartsTypeUI`就可以了 |
||||||
|
|
||||||
以上两个接口,都是在plugin.xml中进行配置以扩展图表类型的,使用class属性来对应相应的扩展类,plotID属性对应图表Plot类型 |
以上两个接口,都是在plugin.xml中进行配置以扩展图表类型的,使用class属性来对应相应的扩展类,plotID属性对应图表类型ID |
||||||
|
|
||||||
## 关键类解释 |
## 关键类解释 |
||||||
|
|
||||||
每实现一种新类型的图表,都需要实现抽象类`AbstractIndependentEChartsProvider`来扩展已有的图表类型引擎以及实现抽象类`AbstractIndependentEChartsUI`类扩展已有的图表类型的设计界面. |
每实现一种新类型的图表,都需要实现抽象类`AbstractEChartsType`来扩展已有的图表类型引擎以及实现抽象类`AbstractEChartsTypeUI`类扩展已有的图表类型的设计界面. |
||||||
|
|
||||||
为了方便统一处理新的图表类型,我们继承内置的`com.fr.chart.chartattr.Chart`类实现一个全新的图表类[com.fr.solution.plugin.chart.echarts.ECharts](echarts.md). |
为了方便统一处理新的图表类型,我们继承内置的`com.fr.chart.impl.AbstractChartWithData`类实现一个全新的图表类[com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts](echarts.md). |
||||||
|
|
||||||
### 继承了AbstractIndependentEChartsProvider的类需要实现以下方法 |
### 继承了AbstractEChartsType的类需要实现以下方法 |
||||||
|
|
||||||
// 该方法用于描述图表的名字 |
// 该方法用户描述图表的子类型,饼图、玫瑰饼图等。 |
||||||
|
|
||||||
`public String getChartName()` |
`public Chart[] getChartTypes()` |
||||||
|
|
||||||
// 该方法用于描述图表的显示名字,会根据不同的语言设置显示不同的名字 |
|
||||||
|
|
||||||
`public String getChartUseName()` |
### 继承了AbstractEChartsTypeUI的类需要实现以下方法 |
||||||
|
|
||||||
// 该方法用户描述图表的子类型 |
// 该方法用于描述图表类型选择界面(一种图表还会有若干种子类型,所以需要这个界面) |
||||||
|
|
||||||
`public Chart[] getChartTypes()` |
[`public AbstractChartTypePane getPlotTypePane()`](echarts_type_pane.md) |
||||||
|
|
||||||
// 该方法用于描述图表对应的图片,一般在设计界面和图表选择界面会看到该图片 |
// 该方法用于描述图表的名字 |
||||||
|
|
||||||
`public String getChartImagePath()` |
`public String getChartName()` |
||||||
|
|
||||||
### 继承了AbstractIndependentEChartsUI的类需要实现以下方法 |
// 该方法用户描述此种类型的图表的小图标,一般在添加表单元素的选择界面可以看到 |
||||||
|
|
||||||
// 该方法用于描述图表类型选择界面(一种图表还会有若干种子类型,所以需要这个界面) |
`public String getIconPath()` |
||||||
|
|
||||||
[`public AbstractChartTypePane getPlotTypePane()`](echarts_type_pane.md) |
// 该方法用于描述图表的子类型的名字 |
||||||
|
|
||||||
// 该方法用于描述此种图表类型的使用数据集数据时的数据设置界面 |
`public String[] getSubName()` |
||||||
|
|
||||||
`public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent)` |
// 该方法用于描述图表对应的图片,图表选择界面使用 |
||||||
|
|
||||||
// 该方法用于描述此种图表类型的使用单元格数据时的数据设置界面 |
`public String[] getDemoImagePath()` |
||||||
|
|
||||||
`public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent)` |
// 该方法用于描述此种图表类型的数据配置界面。默认是分类系列值。 |
||||||
|
|
||||||
// 该方法用户描述此种类型的图表的小图标,一般在添加表单元素的选择界面可以看到 |
`public AbstractDataPane getChartDataPane(AttributeChangeListener listener)` |
||||||
|
|
||||||
`public String getIconPath()` |
|
||||||
|
|
||||||
### 所有新加的实现了XMLAble接口或者其子类的类,都必须要实现相等的判断方法,否者界面设计变化时无法正确检测到属性变化 |
### 所有新加的实现了XMLAble接口或者其子类的类,都必须要实现相等的判断方法,否者界面设计变化时无法正确检测到属性变化 |
||||||
|
|
||||||
`public boolean equals(Object ob)` |
`public boolean equals(Object ob)` |
||||||
|
|
||||||
例如:ECharts,EChartsTooltip等 |
例如:AbstractECharts,EChartsTooltip等 |
@ -1,29 +1,17 @@ |
|||||||
# AbstractEChartsTypePane子类介绍 |
# AbstractEChartsTypePane子类介绍: |
||||||
|
|
||||||
具有子类型的图表,都需要继承该类以实现各种子类型选择以及切换.具体实现可以参考`EChartsPieChartTypePane`. |
具有子类型的图表,都需要继承该类以实现各种子类型选择以及切换.具体实现可以参考`EChartsPieChartTypePane`. |
||||||
|
|
||||||
需要实现几个重要的方法 |
需要实现几个重要的方法 |
||||||
|
|
||||||
// 该选择界面能收的图表类型 |
|
||||||
|
|
||||||
`public boolean accept(Object ob)` |
|
||||||
|
|
||||||
// 默认选中的图表 |
|
||||||
|
|
||||||
`public Chart getDefaultChart()` |
|
||||||
|
|
||||||
// 图表选择界面读取并展现 |
|
||||||
|
|
||||||
`public void populateBean(Chart chart)` |
|
||||||
|
|
||||||
// 获取选中的图表类型 |
|
||||||
|
|
||||||
`public Plot getSelectedClonedPlot()` |
|
||||||
|
|
||||||
// 图表各种子类型的图标 |
// 图表各种子类型的图标 |
||||||
|
|
||||||
`public String[] getIconsOfTypes()` |
`public String[] getIconsOfTypes()` |
||||||
|
|
||||||
// 图表各种子类型的名字 |
// 图表选择界面展现图表属性 |
||||||
|
|
||||||
|
`public void populateBean(T chart)` |
||||||
|
|
||||||
|
// 图表选择界面保存图表属性 |
||||||
|
|
||||||
`public String[] getNamesOfTypes()` |
`public void updateBean(T chart)` |
@ -0,0 +1,158 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.common.base; |
||||||
|
|
||||||
|
import com.fr.base.chart.cross.FormulaProcessor; |
||||||
|
import com.fr.chart.ChartWebParaProvider; |
||||||
|
import com.fr.chart.impl.AbstractChartWithData; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.xml.GeneralXMLTools; |
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.json.JSONException; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.legend.EChartsLegend; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.theme.EChartsTheme; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.title.EChartsTitle; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.tooltip.EChartsTooltip; |
||||||
|
import com.fr.stable.AssistUtils; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/1/29. |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
public abstract class AbstractECharts extends AbstractChartWithData { |
||||||
|
|
||||||
|
private EChartsTheme theme; |
||||||
|
private EChartsTooltip tooltip; |
||||||
|
private EChartsTitle title; |
||||||
|
private EChartsLegend legend; |
||||||
|
|
||||||
|
public AbstractECharts() { |
||||||
|
setTitle(new EChartsTitle()); |
||||||
|
setTooltip(new EChartsTooltip()); |
||||||
|
} |
||||||
|
|
||||||
|
public EChartsTheme getTheme() { |
||||||
|
return theme; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTheme(EChartsTheme theme) { |
||||||
|
this.theme = theme; |
||||||
|
} |
||||||
|
|
||||||
|
public EChartsTooltip getTooltip() { |
||||||
|
return tooltip; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTooltip(EChartsTooltip tooltip) { |
||||||
|
this.tooltip = tooltip; |
||||||
|
} |
||||||
|
|
||||||
|
public EChartsTitle getTitle() { |
||||||
|
return title; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTitle(EChartsTitle title) { |
||||||
|
this.title = title; |
||||||
|
} |
||||||
|
|
||||||
|
public EChartsLegend getLegend() { |
||||||
|
return legend; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLegend(EChartsLegend legend) { |
||||||
|
this.legend = legend; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
super.readXML(reader); |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String tmpNodeName = reader.getTagName(); |
||||||
|
|
||||||
|
if (tmpNodeName.equals(EChartsTheme.XML_TAG)) { |
||||||
|
theme = (EChartsTheme) GeneralXMLTools.readXMLable(reader); |
||||||
|
} else if (tmpNodeName.equals(EChartsTooltip.XML_TAG)) { |
||||||
|
tooltip = (EChartsTooltip) GeneralXMLTools.readXMLable(reader); |
||||||
|
} else if (tmpNodeName.equals(EChartsTitle.XML_TAG)) { |
||||||
|
setTitle(new EChartsTitle()); |
||||||
|
reader.readXMLObject(getTitle()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
super.writeXML(writer); |
||||||
|
if (theme != null) { |
||||||
|
GeneralXMLTools.writeXMLable(writer, theme, EChartsTheme.XML_TAG); |
||||||
|
} |
||||||
|
if (tooltip != null) { |
||||||
|
GeneralXMLTools.writeXMLable(writer, tooltip, EChartsTooltip.XML_TAG); |
||||||
|
} |
||||||
|
if (this.title != null) { |
||||||
|
this.title.writeXML(writer); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object ob) { |
||||||
|
return ob instanceof AbstractECharts |
||||||
|
&& super.equals(ob) |
||||||
|
&& ComparatorUtils.equals(theme, ((AbstractECharts) ob).theme) |
||||||
|
&& ComparatorUtils.equals(title, ((AbstractECharts) ob).title) |
||||||
|
&& ComparatorUtils.equals(legend, ((AbstractECharts) ob).legend) |
||||||
|
&& ComparatorUtils.equals(tooltip, ((AbstractECharts) ob).tooltip); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
return super.hashCode() + AssistUtils.hashCode(theme, tooltip, title, legend); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractECharts clone() throws CloneNotSupportedException { |
||||||
|
AbstractECharts result = (AbstractECharts) super.clone(); |
||||||
|
if (getTheme() != null) { |
||||||
|
result.setTheme(getTheme().clone()); |
||||||
|
} |
||||||
|
if (getTitle() != null) { |
||||||
|
result.setTitle(getTitle().clone()); |
||||||
|
} |
||||||
|
if (getTooltip() != null) { |
||||||
|
result.setTooltip(getTooltip().clone()); |
||||||
|
} |
||||||
|
if (getLegend() != null) { |
||||||
|
result.setLegend((EChartsLegend) getLegend().clone()); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dealFormula(FormulaProcessor formulaProcessor) { |
||||||
|
super.dealFormula(formulaProcessor); |
||||||
|
if (this.getTitle() != null) { |
||||||
|
this.getTitle().dealFormula(formulaProcessor); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Focus(id = EChartsConstants.PLUGIN_ID, text = "", source = Original.PLUGIN) |
||||||
|
public JSONObject createAttributeConfig(ChartWebParaProvider chartWebPara) throws JSONException { |
||||||
|
JSONObject jo = super.createAttributeConfig(chartWebPara); |
||||||
|
|
||||||
|
if (getTitle() != null) { |
||||||
|
jo.put("title", getTitle().createAttributeConfig()); |
||||||
|
} |
||||||
|
|
||||||
|
if (getTheme() != null) { |
||||||
|
jo.put("theme", getTheme().getName()); |
||||||
|
} |
||||||
|
if (getTooltip() != null) { |
||||||
|
jo.put("tooltip", getTooltip().createAttributeConfig()); |
||||||
|
} |
||||||
|
return jo; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,168 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.base; |
|
||||||
|
|
||||||
import com.fr.base.chart.BaseChartGlyph; |
|
||||||
import com.fr.base.chart.chartdata.ChartData; |
|
||||||
import com.fr.chart.chartattr.Chart; |
|
||||||
import com.fr.chart.chartattr.ChartXMLCompatibleUtils; |
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.chart.chartdata.TopDefinition; |
|
||||||
import com.fr.chart.chartglyph.PlotGlyph; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.xml.GeneralXMLTools; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.data.EChartsMoreNameCDDefinition; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.data.EChartsNormalReportDataDefinition; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.data.EChartsOneValueCDDefinition; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsGlyph; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsLegendGlyph; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsTitleGlyph; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.plot.EChartsPlot; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.theme.EChartsTheme; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.title.EChartsTitle; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.tooltip.EChartsTooltip; |
|
||||||
import com.fr.stable.xml.XMLPrintWriter; |
|
||||||
import com.fr.stable.xml.XMLReadable; |
|
||||||
import com.fr.stable.xml.XMLableReader; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/1/29. |
|
||||||
*/ |
|
||||||
public class ECharts extends Chart { |
|
||||||
|
|
||||||
private EChartsTheme theme; |
|
||||||
private EChartsTooltip tooltip; |
|
||||||
|
|
||||||
|
|
||||||
public ECharts() { |
|
||||||
this(null); |
|
||||||
} |
|
||||||
|
|
||||||
public ECharts(EChartsPlot plot) { |
|
||||||
super(plot); |
|
||||||
setWrapperName("EChartsFactory"); |
|
||||||
setTitle(new EChartsTitle()); |
|
||||||
setTooltip(new EChartsTooltip()); |
|
||||||
} |
|
||||||
|
|
||||||
public EChartsTheme getTheme() { |
|
||||||
return theme; |
|
||||||
} |
|
||||||
|
|
||||||
public void setTheme(EChartsTheme theme) { |
|
||||||
this.theme = theme; |
|
||||||
} |
|
||||||
|
|
||||||
public EChartsTooltip getTooltip() { |
|
||||||
return tooltip; |
|
||||||
} |
|
||||||
|
|
||||||
public void setTooltip(EChartsTooltip tooltip) { |
|
||||||
this.tooltip = tooltip; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public BaseChartGlyph createGlyph(ChartData chartData) { |
|
||||||
EChartsGlyph glyph = new EChartsGlyph(); |
|
||||||
glyph.setGeneralInfo(this); |
|
||||||
EChartsPlot EChartsPlot = getPlot(); |
|
||||||
if (EChartsPlot != null) { |
|
||||||
PlotGlyph plotGlyph = EChartsPlot.createPlotGlyph(chartData); |
|
||||||
glyph.setPlotGlyph(plotGlyph); |
|
||||||
EChartsLegendGlyph legendGlyph = EChartsPlot.createLegendGlyph(plotGlyph); |
|
||||||
glyph.setLegendGlyph(legendGlyph); |
|
||||||
} |
|
||||||
EChartsTitle title = (EChartsTitle) getTitle(); |
|
||||||
if (title != null) { |
|
||||||
EChartsTitleGlyph titleGlyph = title.createGlyph(); |
|
||||||
glyph.setTitleGlyph(titleGlyph); |
|
||||||
} |
|
||||||
|
|
||||||
glyph.setWrapperName(getWrapperName()); |
|
||||||
glyph.setChartImagePath(getImagePath()); |
|
||||||
glyph.setRequiredJS(getRequiredJS()); |
|
||||||
glyph.setJSDraw(isJSDraw()); |
|
||||||
|
|
||||||
if (theme != null) { |
|
||||||
glyph.setTheme(theme); |
|
||||||
} |
|
||||||
if (tooltip != null) { |
|
||||||
glyph.setTooltip(tooltip); |
|
||||||
} |
|
||||||
|
|
||||||
return glyph; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 判断图表类型是否是obClass |
|
||||||
* |
|
||||||
* @param obClass 传入对象 |
|
||||||
* @return 是否是obClass对象 |
|
||||||
*/ |
|
||||||
public boolean accept(Class<? extends Chart> obClass) { |
|
||||||
return ComparatorUtils.equals(ECharts.class, obClass); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
protected void readChartXML(XMLableReader reader) { |
|
||||||
if (reader.isChildNode()) { |
|
||||||
String tmpNodeName = reader.getTagName(); |
|
||||||
|
|
||||||
if (tmpNodeName.equals(EChartsTitle.XML_TAG)) { |
|
||||||
setTitle(new EChartsTitle()); |
|
||||||
reader.readXMLObject(getTitle()); |
|
||||||
} else if (tmpNodeName.equals(Plot.XML_TAG)) { |
|
||||||
setPlot((Plot) GeneralXMLTools.readXMLable(reader)); |
|
||||||
} else if (tmpNodeName.equals("ChartAttr")) { |
|
||||||
this.setJSDraw(reader.getAttrAsBoolean("isJSDraw", true)); |
|
||||||
this.setStyleGlobal(reader.getAttrAsBoolean("isStyleGlobal", false)); |
|
||||||
} else if (ComparatorUtils.equals(tmpNodeName, "ChartDefinition")) { |
|
||||||
reader.readXMLObject(new XMLReadable() { |
|
||||||
public void readXML(XMLableReader reader) { |
|
||||||
setFilterDefinition(readDefinition(reader)); |
|
||||||
} |
|
||||||
}); |
|
||||||
} else if (tmpNodeName.equals(EChartsTheme.XML_TAG)) { |
|
||||||
theme = (EChartsTheme) GeneralXMLTools.readXMLable(reader); |
|
||||||
} else if (tmpNodeName.equals(EChartsTooltip.XML_TAG)) { |
|
||||||
tooltip = (EChartsTooltip) GeneralXMLTools.readXMLable(reader); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static TopDefinition readDefinition(XMLableReader reader) { |
|
||||||
TopDefinition filterDefinition; |
|
||||||
String tmpNodeName = reader.getTagName(); |
|
||||||
if (EChartsOneValueCDDefinition.XML_TAG.equals(tmpNodeName)) { |
|
||||||
filterDefinition = new EChartsOneValueCDDefinition(); |
|
||||||
} else if (EChartsMoreNameCDDefinition.XML_TAG.equals(tmpNodeName)) { |
|
||||||
filterDefinition = new EChartsMoreNameCDDefinition(); |
|
||||||
} else if (EChartsNormalReportDataDefinition.XML_TAG.equals(tmpNodeName)) { |
|
||||||
filterDefinition = new EChartsNormalReportDataDefinition(); |
|
||||||
} else { |
|
||||||
return ChartXMLCompatibleUtils.readDefinition(reader); |
|
||||||
} |
|
||||||
|
|
||||||
reader.readXMLObject(filterDefinition); |
|
||||||
return filterDefinition; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void writeXML(XMLPrintWriter writer) { |
|
||||||
super.writeXML(writer); |
|
||||||
if (theme != null) { |
|
||||||
GeneralXMLTools.writeXMLable(writer, theme, EChartsTheme.XML_TAG); |
|
||||||
} |
|
||||||
if (tooltip != null) { |
|
||||||
GeneralXMLTools.writeXMLable(writer, tooltip, EChartsTooltip.XML_TAG); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean equals(Object ob) { |
|
||||||
return ob instanceof ECharts |
|
||||||
&& super.equals(ob) |
|
||||||
&& ComparatorUtils.equals(theme, ((ECharts) ob).theme) |
|
||||||
&& ComparatorUtils.equals(tooltip, ((ECharts) ob).tooltip); |
|
||||||
} |
|
||||||
} |
|
@ -1,19 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.data; |
|
||||||
|
|
||||||
import com.fr.chart.chartdata.MoreNameCDDefinition; |
|
||||||
import com.fr.chart.chartdata.NormalChartData; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by Mitisky on 16/1/19. |
|
||||||
*/ |
|
||||||
public class EChartsMoreNameCDDefinition extends MoreNameCDDefinition { |
|
||||||
|
|
||||||
private static final long serialVersionUID = -2555257182076448042L; |
|
||||||
|
|
||||||
protected NormalChartData getNormalChartData(Object[] series_name_array, Object[][] series_v_2D) { |
|
||||||
NormalChartData normal = new EChartsNormalChartData(categoryLabels, series_name_array, series_v_2D); |
|
||||||
normal.setSecondCates(secondLabels); |
|
||||||
normal.setThirdCates(thirdLabels); |
|
||||||
return normal; |
|
||||||
} |
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.data; |
|
||||||
|
|
||||||
import com.fr.chart.chartdata.NormalChartData; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by Mitisky on 16/1/19. |
|
||||||
* 不做大数据过滤 |
|
||||||
*/ |
|
||||||
public class EChartsNormalChartData extends NormalChartData { |
|
||||||
|
|
||||||
public EChartsNormalChartData() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public EChartsNormalChartData(Object[] category_array, Object[] series_array, Object[][] series_value_2D) { |
|
||||||
super(category_array, series_array, series_value_2D); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 处理大数据.1000分类. |
|
||||||
* 不做任何处理 |
|
||||||
*/ |
|
||||||
public void dealHugeData() { |
|
||||||
//新的图表数据不在这里处理大数据
|
|
||||||
//画图的时候处理:折线图相同像素点只画一个,其他图表有配置是否采用大数据模式。
|
|
||||||
} |
|
||||||
} |
|
@ -1,17 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.data; |
|
||||||
|
|
||||||
import com.fr.chart.chartdata.NormalChartData; |
|
||||||
import com.fr.chart.chartdata.NormalReportDataDefinition; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by Mitisky on 16/1/19. |
|
||||||
* |
|
||||||
*/ |
|
||||||
public class EChartsNormalReportDataDefinition extends NormalReportDataDefinition { |
|
||||||
|
|
||||||
private static final long serialVersionUID = -645098535257304519L; |
|
||||||
|
|
||||||
protected NormalChartData getNormalDataObject() { |
|
||||||
return new EChartsNormalChartData(); |
|
||||||
} |
|
||||||
} |
|
@ -1,19 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.data; |
|
||||||
|
|
||||||
import com.fr.chart.chartdata.NormalChartData; |
|
||||||
import com.fr.chart.chartdata.OneValueCDDefinition; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by Mitisky on 16/1/19. |
|
||||||
*/ |
|
||||||
public class EChartsOneValueCDDefinition extends OneValueCDDefinition { |
|
||||||
|
|
||||||
private static final long serialVersionUID = -7069079313068958054L; |
|
||||||
|
|
||||||
protected NormalChartData getNormalChartData(Object[] series_name_array, Object[][] series_v_2D) { |
|
||||||
NormalChartData normal = new EChartsNormalChartData(categoryLabels, series_name_array, series_v_2D); |
|
||||||
normal.setSecondCates(secondLabels); |
|
||||||
normal.setThirdCates(thirdLabels); |
|
||||||
return normal; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.common.data; |
||||||
|
|
||||||
|
import com.fr.chartx.data.annotations.KeyField; |
||||||
|
import com.fr.chartx.data.field.ColumnField; |
||||||
|
import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author shine |
||||||
|
* @version 10.0 |
||||||
|
* Created by shine on 2019/10/23 |
||||||
|
* <p> |
||||||
|
* 分类、系列、值三个字段 |
||||||
|
*/ |
||||||
|
public class NormalEChartsColumnFieldCollection extends AbstractColumnFieldCollectionWithSeriesValue { |
||||||
|
|
||||||
|
@KeyField |
||||||
|
private ColumnField category = new ColumnField(); |
||||||
|
|
||||||
|
public ColumnField getCategory() { |
||||||
|
return category; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCategory(ColumnField category) { |
||||||
|
this.category = category; |
||||||
|
} |
||||||
|
} |
@ -1,53 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.glyph; |
|
||||||
|
|
||||||
import com.fr.chart.chartglyph.ChartGlyph; |
|
||||||
import com.fr.json.JSONArray; |
|
||||||
import com.fr.json.JSONException; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.theme.EChartsTheme; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.tooltip.EChartsTooltip; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
import com.fr.stable.web.Repository; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/1/29. |
|
||||||
*/ |
|
||||||
public class EChartsGlyph extends ChartGlyph { |
|
||||||
|
|
||||||
private EChartsTheme theme; |
|
||||||
private EChartsTooltip tooltip; |
|
||||||
|
|
||||||
public void setTheme(EChartsTheme theme) { |
|
||||||
this.theme = theme; |
|
||||||
} |
|
||||||
|
|
||||||
public void setTooltip(EChartsTooltip tooltip) { |
|
||||||
this.tooltip = tooltip; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JSONObject toJSONObject(Repository repo) throws JSONException { |
|
||||||
JSONObject jo = JSONObject.create(); |
|
||||||
EChartsTitleGlyph titleGlyph = (EChartsTitleGlyph) getTitleGlyph(); |
|
||||||
if (titleGlyph != null) { |
|
||||||
jo.put("title", titleGlyph.toJSONObject(repo)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
EChartsLegendGlyph legendGlyph = (EChartsLegendGlyph) getLegendGlyph(); |
|
||||||
if (legendGlyph != null) { |
|
||||||
jo.put("legend", legendGlyph.toJSONObject(repo)); |
|
||||||
} |
|
||||||
EChartsPlotGlyph plotGlyph = (EChartsPlotGlyph) getPlotGlyph(); |
|
||||||
if (plotGlyph != null) { |
|
||||||
jo.put("series", plotGlyph.toSeriesData(repo)); |
|
||||||
} |
|
||||||
if (theme != null) { |
|
||||||
jo.put("theme", theme.getName()); |
|
||||||
} |
|
||||||
if (tooltip != null) { |
|
||||||
jo.put("tooltip", tooltip.toJSONObject(repo)); |
|
||||||
} |
|
||||||
return jo; |
|
||||||
} |
|
||||||
} |
|
@ -1,38 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.glyph; |
|
||||||
|
|
||||||
import com.fr.chart.chartglyph.LegendGlyph; |
|
||||||
import com.fr.chart.chartglyph.LegendItem; |
|
||||||
import com.fr.json.JSONArray; |
|
||||||
import com.fr.json.JSONException; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.stable.ArrayUtils; |
|
||||||
import com.fr.stable.web.Repository; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/2. |
|
||||||
*/ |
|
||||||
public class EChartsLegendGlyph extends LegendGlyph { |
|
||||||
|
|
||||||
public EChartsLegendGlyph(LegendItem[] items) { |
|
||||||
super(items); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JSONObject toJSONObject(Repository repo) throws JSONException { |
|
||||||
JSONObject result = JSONObject.create() |
|
||||||
.put("orient", "horizontal") |
|
||||||
.put("y", "bottom"); |
|
||||||
LegendItem[] items = getItems(); |
|
||||||
|
|
||||||
if (ArrayUtils.isNotEmpty(items)) { |
|
||||||
JSONArray data = JSONArray.create(); |
|
||||||
result.put("data", data); |
|
||||||
for (LegendItem item : items) { |
|
||||||
JSONObject jo = item.toJSONObject(repo); |
|
||||||
data.put(jo.optString("label")); |
|
||||||
} |
|
||||||
} |
|
||||||
return result; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,30 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.glyph; |
|
||||||
|
|
||||||
import com.fr.chart.chartglyph.PlotGlyph; |
|
||||||
import com.fr.json.JSONArray; |
|
||||||
import com.fr.json.JSONException; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.stable.web.Repository; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public abstract class EChartsPlotGlyph extends PlotGlyph { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void layoutAxisGlyph(int resolution) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void layoutDataSeriesGlyph(int resolution) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JSONObject toJSONObject(Repository repo) throws JSONException { |
|
||||||
throw new UnsupportedOperationException("Not support yet!"); |
|
||||||
} |
|
||||||
|
|
||||||
public abstract JSONArray toSeriesData(Repository repo) throws JSONException; |
|
||||||
} |
|
@ -1,30 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.glyph; |
|
||||||
|
|
||||||
import com.fr.chart.chartglyph.TitleGlyph; |
|
||||||
import com.fr.json.JSONException; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.stable.web.Repository; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/2. |
|
||||||
*/ |
|
||||||
public class EChartsTitleGlyph extends TitleGlyph { |
|
||||||
|
|
||||||
|
|
||||||
public EChartsTitleGlyph(String title) { |
|
||||||
setText(title); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JSONObject toJSONObject(Repository repo) throws JSONException { |
|
||||||
return createTitle(repo); |
|
||||||
} |
|
||||||
|
|
||||||
private JSONObject createTitle(Repository repo) throws JSONException { |
|
||||||
JSONObject t = JSONObject.create() |
|
||||||
.put("text", getText()) |
|
||||||
.put("x", "center"); |
|
||||||
t.put("show", isVisible()); |
|
||||||
return t; |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.plot; |
|
||||||
|
|
||||||
import com.fr.chart.chartattr.Legend; |
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.chart.chartglyph.PlotGlyph; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsLegendGlyph; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.legend.EChartsLegend; |
|
||||||
import com.fr.stable.xml.XMLableReader; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/2. |
|
||||||
*/ |
|
||||||
public abstract class EChartsPlot extends Plot { |
|
||||||
|
|
||||||
public EChartsPlot() { |
|
||||||
setLegend(new EChartsLegend()); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean accept(Class<? extends Plot> obClass) { |
|
||||||
return ComparatorUtils.equals(EChartsPlot.class, obClass); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public EChartsLegendGlyph createLegendGlyph(PlotGlyph plotGlyph) { |
|
||||||
EChartsLegend legend = (EChartsLegend) getLegend(); |
|
||||||
if (legend == null) { |
|
||||||
legend = new EChartsLegend(); |
|
||||||
setLegend(legend); |
|
||||||
} |
|
||||||
return legend.createLegendGlyph(createLegendItems(plotGlyph)); |
|
||||||
} |
|
||||||
|
|
||||||
protected void readPlotXML(XMLableReader reader){ |
|
||||||
if (reader.isChildNode()) { |
|
||||||
String tagName = reader.getTagName(); |
|
||||||
|
|
||||||
if (EChartsLegend.XML_TAG.equals(tagName)) { |
|
||||||
setLegend((Legend)reader.readXMLObject(new EChartsLegend())); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.common.ui; |
||||||
|
|
||||||
|
import com.fr.design.chart.fun.impl.AbstractChartTypeUI; |
||||||
|
import com.fr.design.chartx.impl.AbstractDataPane; |
||||||
|
import com.fr.design.chartx.impl.AbstractOtherPane; |
||||||
|
import com.fr.design.chartx.single.SingleDataPane; |
||||||
|
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.ui.data.NormalEChartsCellDataPane; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.ui.data.NormalEChartsDataSetPane; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/2/18. |
||||||
|
*/ |
||||||
|
public abstract class AbstractEChartsTypeUI extends AbstractChartTypeUI { |
||||||
|
|
||||||
|
private EChartsStylePane stylePane; |
||||||
|
|
||||||
|
public AbstractOtherPane[] getAttrPaneArray(AttributeChangeListener listener) { |
||||||
|
if (stylePane == null) { |
||||||
|
stylePane = new EChartsStylePane(listener); |
||||||
|
} |
||||||
|
return new AbstractOtherPane[]{stylePane}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractDataPane getChartDataPane(AttributeChangeListener listener) { |
||||||
|
return new AbstractDataPane(listener) { |
||||||
|
@Override |
||||||
|
protected SingleDataPane createSingleDataPane() { |
||||||
|
return new SingleDataPane(new NormalEChartsDataSetPane(), new NormalEChartsCellDataPane()); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,30 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.ui; |
|
||||||
|
|
||||||
import com.fr.design.chart.fun.impl.AbstractIndependentChartUIWithAPILevel; |
|
||||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
|
||||||
import com.fr.design.mainframe.chart.AbstractChartAttrPane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public abstract class AbstractIndependentEChartsUI extends AbstractIndependentChartUIWithAPILevel { |
|
||||||
|
|
||||||
private EChartsStylePane stylePane; |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean isUseDefaultPane() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener){ |
|
||||||
if (stylePane == null) { |
|
||||||
stylePane = new EChartsStylePane(listener); |
|
||||||
} |
|
||||||
return new AbstractChartAttrPane[]{stylePane}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int currentAPILevel() { |
|
||||||
return CURRENT_API_LEVEL; |
|
||||||
} |
|
||||||
} |
|
@ -1,14 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.ui.data; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.data.report.CategoryPlotReportDataContentPane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public class AbstractEChartsReportDataContentPane extends CategoryPlotReportDataContentPane { |
|
||||||
|
|
||||||
public AbstractEChartsReportDataContentPane(ChartDataPane parent) { |
|
||||||
super(parent); |
|
||||||
} |
|
||||||
} |
|
@ -1,14 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.ui.data; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/1/29. |
|
||||||
*/ |
|
||||||
public class AbstractEChartsTableDataContentPane extends CategoryPlotTableDataContentPane { |
|
||||||
|
|
||||||
public AbstractEChartsTableDataContentPane(ChartDataPane parent) { |
|
||||||
super(parent); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,50 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.common.ui.data; |
||||||
|
|
||||||
|
import com.fr.design.chartx.fields.diff.AbstractCellDataFieldsWithSeriesValuePane; |
||||||
|
import com.fr.design.formula.TinyFormulaPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.data.NormalEChartsColumnFieldCollection; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author shine |
||||||
|
* @version 10.0 |
||||||
|
* Created by shine on 2019/10/23 |
||||||
|
*/ |
||||||
|
public class NormalEChartsCellDataPane extends AbstractCellDataFieldsWithSeriesValuePane<NormalEChartsColumnFieldCollection> { |
||||||
|
private TinyFormulaPane category; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String[] fieldLabels() { |
||||||
|
return new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category_Name") |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected TinyFormulaPane[] formulaPanes() { |
||||||
|
return new TinyFormulaPane[]{ |
||||||
|
getCategory() |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
private TinyFormulaPane getCategory() { |
||||||
|
if (category == null) { |
||||||
|
category = new TinyFormulaPane(); |
||||||
|
} |
||||||
|
return category; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(NormalEChartsColumnFieldCollection ob) { |
||||||
|
populateSeriesValuePane(ob); |
||||||
|
populateField(category, ob.getCategory()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public NormalEChartsColumnFieldCollection updateBean() { |
||||||
|
NormalEChartsColumnFieldCollection columnFieldCollection = new NormalEChartsColumnFieldCollection(); |
||||||
|
updateSeriesValuePane(columnFieldCollection); |
||||||
|
updateField(category, columnFieldCollection.getCategory()); |
||||||
|
return columnFieldCollection; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.common.ui.data; |
||||||
|
|
||||||
|
import com.fr.design.chartx.fields.diff.AbstractDataSetFieldsWithSeriesValuePane; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.extended.chart.UIComboBoxWithNone; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.data.NormalEChartsColumnFieldCollection; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author shine |
||||||
|
* @version 10.0 |
||||||
|
* Created by shine on 2019/10/23 |
||||||
|
*/ |
||||||
|
public class NormalEChartsDataSetPane extends AbstractDataSetFieldsWithSeriesValuePane<NormalEChartsColumnFieldCollection> { |
||||||
|
private UIComboBox category; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String[] fieldLabels() { |
||||||
|
return new String[]{ |
||||||
|
Toolkit.i18nText("Fine-Design_Chart_Category_Name") |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected UIComboBox[] filedComboBoxes() { |
||||||
|
return new UIComboBox[]{ |
||||||
|
getCategory() |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private UIComboBox getCategory() { |
||||||
|
if (category == null) { |
||||||
|
category = new UIComboBoxWithNone(); |
||||||
|
} |
||||||
|
return category; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(NormalEChartsColumnFieldCollection ob) { |
||||||
|
populateSeriesValuePane(ob); |
||||||
|
populateField(category, ob.getCategory()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public NormalEChartsColumnFieldCollection updateBean() { |
||||||
|
NormalEChartsColumnFieldCollection columnFieldCollection = new NormalEChartsColumnFieldCollection(); |
||||||
|
updateSeriesValuePane(columnFieldCollection); |
||||||
|
updateField(category, columnFieldCollection.getCategory()); |
||||||
|
return columnFieldCollection; |
||||||
|
} |
||||||
|
} |
@ -1,36 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.ui.filter; |
|
||||||
|
|
||||||
import com.fr.chart.chartattr.ChartCollection; |
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.style.ThirdTabPane; |
|
||||||
|
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public class NewDataFilterPane extends ThirdTabPane<ChartCollection> { |
|
||||||
|
|
||||||
public NewDataFilterPane(Plot plot, ChartDataPane parent) { |
|
||||||
super(plot, parent); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected List<NamePane> initPaneList(Plot plot, AbstractAttrNoScrollPane parent) { |
|
||||||
List<NamePane> paneList = new ArrayList<NamePane>(); |
|
||||||
return paneList; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void populateBean(ChartCollection ob) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String title4PopupWindow() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
@ -1,159 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.common.ui.series; |
|
||||||
|
|
||||||
import com.fr.base.chart.chartdata.TopDefinitionProvider; |
|
||||||
import com.fr.chart.chartattr.ChartCollection; |
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.chart.chartdata.MoreNameCDDefinition; |
|
||||||
import com.fr.chart.chartdata.OneValueCDDefinition; |
|
||||||
import com.fr.design.beans.FurtherBasicBeanPane; |
|
||||||
import com.fr.design.constants.LayoutConstants; |
|
||||||
import com.fr.design.gui.frpane.UIComboBoxPane; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldNamePane; |
|
||||||
import com.fr.design.mainframe.chart.gui.data.table.SeriesNameUseFieldValuePane; |
|
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.ui.filter.NewDataFilterPane; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
import java.awt.*; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
public class NewSeriesTypeUsePane extends UIComboBoxPane<ChartCollection> { |
|
||||||
|
|
||||||
private SeriesNameUseFieldValuePane nameFieldValuePane; |
|
||||||
private SeriesNameUseFieldNamePane nameFieldNamePane; |
|
||||||
|
|
||||||
private NewDataFilterPane dataFilterPane; |
|
||||||
|
|
||||||
private ChartDataPane parent; |
|
||||||
private Plot initplot; |
|
||||||
|
|
||||||
private boolean isNeedSummary = true; |
|
||||||
|
|
||||||
public NewSeriesTypeUsePane(ChartDataPane parent, Plot initPlot) { |
|
||||||
cards = initPaneList(); |
|
||||||
this.parent = parent; |
|
||||||
this.initplot = initPlot; |
|
||||||
this.isNeedSummary = true; |
|
||||||
initComponents(); |
|
||||||
} |
|
||||||
|
|
||||||
protected void initLayout() { |
|
||||||
this.setLayout(new BorderLayout(4, LayoutConstants.VGAP_MEDIUM)); |
|
||||||
JPanel northPane = new JPanel(new BorderLayout(4, 0)); |
|
||||||
UILabel label1 = new UILabel(Inter.getLocText("ChartF-Series_Name_From") + ":", SwingConstants.RIGHT); |
|
||||||
label1.setPreferredSize(new Dimension(75, 20)); |
|
||||||
northPane.add(GUICoreUtils.createBorderLayoutPane( |
|
||||||
jcb, BorderLayout.CENTER, |
|
||||||
label1, BorderLayout.WEST |
|
||||||
)); |
|
||||||
northPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1)); |
|
||||||
add(northPane, BorderLayout.NORTH); |
|
||||||
add(cardPane, BorderLayout.CENTER); |
|
||||||
|
|
||||||
dataFilterPane = new NewDataFilterPane(initplot, parent); |
|
||||||
add(dataFilterPane, BorderLayout.SOUTH); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 检查box 是否使用, hasUse, 表示上层已经使用, 否则, 则此界面都可使用 |
|
||||||
* |
|
||||||
* @param hasUse 是否使用 |
|
||||||
*/ |
|
||||||
public void checkUseBox(boolean hasUse) { |
|
||||||
jcb.setEnabled(hasUse); |
|
||||||
nameFieldValuePane.checkUse(hasUse); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 切换 变更数据集时, 刷新Box选中项目 |
|
||||||
* |
|
||||||
* @param list 列表 |
|
||||||
*/ |
|
||||||
public void refreshBoxListWithSelectTableData(List list) { |
|
||||||
nameFieldValuePane.refreshBoxListWithSelectTableData(list); |
|
||||||
nameFieldNamePane.refreshBoxListWithSelectTableData(list); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 清空所有的box设置 |
|
||||||
*/ |
|
||||||
public void clearAllBoxList() { |
|
||||||
nameFieldValuePane.clearAllBoxList(); |
|
||||||
nameFieldNamePane.clearAllBoxList(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 界面标题 |
|
||||||
* |
|
||||||
* @return 界面标题 |
|
||||||
*/ |
|
||||||
protected String title4PopupWindow() { |
|
||||||
return Inter.getLocText("ChartF-Series_Name_From"); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected List<FurtherBasicBeanPane<? extends ChartCollection>> initPaneList() { |
|
||||||
nameFieldValuePane = new SeriesNameUseFieldValuePane(); |
|
||||||
nameFieldNamePane = new SeriesNameUseFieldNamePane(); |
|
||||||
List<FurtherBasicBeanPane<? extends ChartCollection>> paneList = new ArrayList<FurtherBasicBeanPane<? extends ChartCollection>>(); |
|
||||||
paneList.add(nameFieldValuePane); |
|
||||||
paneList.add(nameFieldNamePane); |
|
||||||
return paneList; |
|
||||||
} |
|
||||||
|
|
||||||
public void populateBean(ChartCollection ob, boolean isNeedSummary) { |
|
||||||
this.isNeedSummary = isNeedSummary; |
|
||||||
TopDefinitionProvider definition = ob.getSelectedChart().getFilterDefinition(); |
|
||||||
if (definition instanceof OneValueCDDefinition) { |
|
||||||
this.setSelectedIndex(0); |
|
||||||
nameFieldValuePane.populateBean(ob, isNeedSummary); |
|
||||||
} else if (definition instanceof MoreNameCDDefinition) { |
|
||||||
this.setSelectedIndex(1); |
|
||||||
nameFieldNamePane.populateBean(ob, isNeedSummary); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 重新布局整个面板 |
|
||||||
* |
|
||||||
* @param isNeedSummary 是否需要汇总 |
|
||||||
*/ |
|
||||||
public void relayoutPane(boolean isNeedSummary) { |
|
||||||
this.isNeedSummary = isNeedSummary; |
|
||||||
if (jcb.getSelectedIndex() == 0) { |
|
||||||
nameFieldValuePane.relayoutPane(this.isNeedSummary); |
|
||||||
} else { |
|
||||||
nameFieldNamePane.relayoutPane(this.isNeedSummary); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
protected void comboBoxItemStateChanged() { |
|
||||||
if (jcb.getSelectedIndex() == 0) { |
|
||||||
nameFieldValuePane.relayoutPane(this.isNeedSummary); |
|
||||||
} else { |
|
||||||
nameFieldNamePane.relayoutPane(this.isNeedSummary); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void populateBean(ChartCollection ob) { |
|
||||||
this.populateBean(ob, true); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 保存界面属性到Ob-ChartCollection |
|
||||||
*/ |
|
||||||
public void updateBean(ChartCollection ob) { |
|
||||||
if (this.getSelectedIndex() == 0) { |
|
||||||
nameFieldValuePane.updateBean(ob); |
|
||||||
} else { |
|
||||||
nameFieldNamePane.updateBean(ob); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,40 +1,155 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie; |
package com.fr.solution.plugin.chart.echarts.pie; |
||||||
|
|
||||||
import com.fr.chart.chartattr.Chart; |
import com.fr.chart.ChartWebParaProvider; |
||||||
import com.fr.solution.plugin.chart.echarts.common.base.AbstractIndependentEChartsProvider; |
import com.fr.chartx.TwoTuple; |
||||||
import com.fr.solution.plugin.chart.echarts.common.base.ECharts; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.solution.plugin.chart.echarts.pie.plot.EChartsPiePlot; |
import com.fr.general.GeneralUtils; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONException; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.data.NormalEChartsColumnFieldCollection; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.legend.EChartsLegend; |
||||||
import com.fr.solution.plugin.chart.echarts.pie.plot.RoseType; |
import com.fr.solution.plugin.chart.echarts.pie.plot.RoseType; |
||||||
|
import com.fr.stable.AssistUtils; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
import java.text.DecimalFormat; |
||||||
|
import java.text.NumberFormat; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by richie on 16/2/18. |
* @author shine |
||||||
|
* @version 10.0 |
||||||
|
* Created by shine on 2019/10/23 |
||||||
*/ |
*/ |
||||||
public class EChartsPie extends AbstractIndependentEChartsProvider { |
public class EChartsPie extends AbstractECharts { |
||||||
|
private static final NumberFormat format = new DecimalFormat("##%"); |
||||||
|
|
||||||
|
private RoseType roseType = RoseType.NONE; |
||||||
|
|
||||||
|
public EChartsPie() { |
||||||
|
} |
||||||
|
|
||||||
|
public EChartsPie(RoseType roseType) { |
||||||
|
this.roseType = roseType; |
||||||
|
} |
||||||
|
|
||||||
|
public RoseType getRoseType() { |
||||||
|
return roseType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRoseType(RoseType roseType) { |
||||||
|
this.roseType = roseType; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getID() { |
||||||
|
return "EChartsPiePlot"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject createAttributeConfig(ChartWebParaProvider chartWebPara) throws JSONException { |
||||||
|
JSONObject jo = super.createAttributeConfig(chartWebPara); |
||||||
|
|
||||||
|
jo.put("series", toSeriesData()); |
||||||
|
|
||||||
|
NormalEChartsColumnFieldCollection fieldCollection = getFieldCollection(NormalEChartsColumnFieldCollection.class); |
||||||
|
List<Object> seriesList = fieldCollection.getSeriesValueCorrelationDefinition().getResultSeriesValue().getSeries().getValues(); |
||||||
|
|
||||||
|
jo.put("legend", EChartsLegend.createAttributeConfig(getNoRepeatCount(seriesList).getFirst())); |
||||||
|
|
||||||
|
return jo; |
||||||
|
} |
||||||
|
|
||||||
|
private TwoTuple<Object[], Integer> getNoRepeatCount(List<Object> categoryList) { |
||||||
|
Set<Object> noRepeatCategorySet = new HashSet<Object>(); |
||||||
|
noRepeatCategorySet.addAll(categoryList); |
||||||
|
return new TwoTuple<>(noRepeatCategorySet.toArray(), noRepeatCategorySet.size()); |
||||||
|
} |
||||||
|
|
||||||
|
private JSONArray toSeriesData() throws JSONException { |
||||||
|
NormalEChartsColumnFieldCollection fieldCollection = getFieldCollection(NormalEChartsColumnFieldCollection.class); |
||||||
|
List<Object> categoryList = fieldCollection.getCategory().getValues(); |
||||||
|
List<Object> seriesList = fieldCollection.getSeriesValueCorrelationDefinition().getResultSeriesValue().getSeries().getValues(); |
||||||
|
List<Object> valueList = fieldCollection.getSeriesValueCorrelationDefinition().getResultSeriesValue().getValue().getValues(); |
||||||
|
|
||||||
|
TwoTuple<Object[], Integer> aboutCate = getNoRepeatCount(categoryList); |
||||||
|
|
||||||
private static ECharts createPie(RoseType type) { |
JSONArray result = JSONArray.create(); |
||||||
EChartsPiePlot plot = new EChartsPiePlot(type); |
int cn = aboutCate.getSecond(); |
||||||
return new ECharts(plot); |
String r = "100%"; |
||||||
|
if (cn > 1) { |
||||||
|
r = format.format(1.0 / (cn + 1)); |
||||||
} |
} |
||||||
|
Object[] noRepeatArray = aboutCate.getFirst(); |
||||||
|
for (int c = 0; c < cn; c++) { |
||||||
|
String categoryName = GeneralUtils.objectToString(noRepeatArray[c]); |
||||||
|
JSONObject wrapper = JSONObject.create(); |
||||||
|
result.put(wrapper); |
||||||
|
wrapper.put("type", "pie"); |
||||||
|
if (cn > 1) { |
||||||
|
wrapper.put("radius", r); |
||||||
|
wrapper.put("center", JSONArray.create().put(format.format(1.0 * c / (cn + 1) + 0.20)).put("55%")); |
||||||
|
} |
||||||
|
if (getRoseType() != RoseType.NONE) { |
||||||
|
wrapper.put("roseType", roseType.toTypeString()); |
||||||
|
} |
||||||
|
wrapper.put("itemStyle", |
||||||
|
JSONObject.create().put("normal", |
||||||
|
JSONObject.create().put("label", |
||||||
|
JSONObject.create().put("formatter", "{c}")))); |
||||||
|
JSONArray data = JSONArray.create(); |
||||||
|
wrapper.put("data", data); |
||||||
|
wrapper.put("name", categoryName); |
||||||
|
|
||||||
public static ECharts[] charts = new ECharts[] { |
for (int i = 0, len = seriesList.size(); i < len; i++) { |
||||||
createPie(RoseType.NONE), |
if (ComparatorUtils.equals(categoryName, categoryList.get(i))) { |
||||||
createPie(RoseType.AREA), |
|
||||||
createPie(RoseType.RADIUS), |
|
||||||
}; |
|
||||||
|
|
||||||
|
JSONObject item = JSONObject.create(); |
||||||
|
data.put(item); |
||||||
|
item.put("name", seriesList.get(i)); |
||||||
|
item.put("value", valueList.get(i)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void readAttr(XMLableReader xmLableReader) { |
||||||
|
super.readAttr(xmLableReader); |
||||||
|
this.setRoseType(RoseType.parse(xmLableReader.getAttrAsString("roseType", StringUtils.EMPTY))); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void writeAttr(XMLPrintWriter xmlPrintWriter) { |
||||||
|
super.writeAttr(xmlPrintWriter); |
||||||
|
xmlPrintWriter.attr("roseType", this.getRoseType().toTypeString()); |
||||||
|
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String getChartName() { |
public boolean equals(Object ob) { |
||||||
return "Plugin-ECharts_Pie"; |
return ob instanceof EChartsPie |
||||||
|
&& ((EChartsPie) ob).getRoseType() == this.getRoseType() |
||||||
|
&& super.equals(ob); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public Chart[] getChartTypes() { |
public int hashCode() { |
||||||
return charts; |
return super.hashCode() + AssistUtils.hashCode(roseType); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String getChartImagePath() { |
public EChartsPie clone() throws CloneNotSupportedException { |
||||||
return "com/fr/solution/plugin/chart/echarts/pie/images/pie256.png"; |
EChartsPie result = (EChartsPie) super.clone(); |
||||||
|
result.roseType = this.getRoseType(); |
||||||
|
return result; |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,27 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.pie; |
||||||
|
|
||||||
|
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.base.AbstractEChartsType; |
||||||
|
import com.fr.solution.plugin.chart.echarts.pie.plot.RoseType; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/2/18. |
||||||
|
*/ |
||||||
|
public class EChartsPieType extends AbstractEChartsType { |
||||||
|
|
||||||
|
private static AbstractECharts[] eCharts = new AbstractECharts[]{ |
||||||
|
createPie(RoseType.NONE), |
||||||
|
createPie(RoseType.AREA), |
||||||
|
createPie(RoseType.RADIUS), |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractECharts[] getChartTypes() { |
||||||
|
return eCharts; |
||||||
|
} |
||||||
|
|
||||||
|
private static AbstractECharts createPie(RoseType type) { |
||||||
|
return new EChartsPie(type); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.fr.solution.plugin.chart.echarts.pie; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; |
||||||
|
import com.fr.locale.InterProviderFactory; |
||||||
|
import com.fr.solution.plugin.chart.echarts.common.ui.AbstractEChartsTypeUI; |
||||||
|
import com.fr.solution.plugin.chart.echarts.pie.ui.EChartsPieChartTypePane; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 16/1/29. |
||||||
|
*/ |
||||||
|
public class EChartsPieTypeUI extends AbstractEChartsTypeUI { |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractChartTypePane getPlotTypePane() { |
||||||
|
return new EChartsPieChartTypePane(); |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return InterProviderFactory.getProvider().getLocText("Plugin-ECharts_Pie"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String[] getSubName() { |
||||||
|
return new String[]{ |
||||||
|
"Normal", |
||||||
|
"Area", |
||||||
|
"Redius" |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
public String[] getDemoImagePath() { |
||||||
|
return new String[]{ |
||||||
|
"com/fr/solution/plugin/chart/echarts/pie/images/pie256.png", |
||||||
|
"com/fr/solution/plugin/chart/echarts/pie/images/pie256.png", |
||||||
|
"com/fr/solution/plugin/chart/echarts/pie/images/pie256.png" |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getIconPath() { |
||||||
|
return "com/fr/solution/plugin/chart/echarts/pie/images/pie.png"; |
||||||
|
} |
||||||
|
} |
@ -1,37 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie; |
|
||||||
|
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; |
|
||||||
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.ui.AbstractIndependentEChartsUI; |
|
||||||
import com.fr.solution.plugin.chart.echarts.pie.ui.EChartsPieChartTypePane; |
|
||||||
import com.fr.solution.plugin.chart.echarts.pie.ui.EChartsPieReportDataContentPane; |
|
||||||
import com.fr.solution.plugin.chart.echarts.pie.ui.EChartsPieTableDataContentPane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/1/29. |
|
||||||
*/ |
|
||||||
public class EChartsPieUI extends AbstractIndependentEChartsUI { |
|
||||||
|
|
||||||
@Override |
|
||||||
public AbstractChartTypePane getPlotTypePane() { |
|
||||||
return new EChartsPieChartTypePane(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { |
|
||||||
return new EChartsPieTableDataContentPane(parent); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { |
|
||||||
return new EChartsPieReportDataContentPane(parent); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getIconPath() { |
|
||||||
return "com/fr/solution/plugin/chart/echarts/pie/images/pie.png"; |
|
||||||
} |
|
||||||
} |
|
@ -1,88 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie.glyph; |
|
||||||
|
|
||||||
import com.fr.chart.chartglyph.DataPoint; |
|
||||||
import com.fr.chart.chartglyph.DataSeries; |
|
||||||
import com.fr.intelli.record.Focus; |
|
||||||
import com.fr.intelli.record.Original; |
|
||||||
import com.fr.json.JSONArray; |
|
||||||
import com.fr.json.JSONException; |
|
||||||
import com.fr.json.JSONFunction; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.record.analyzer.EnableMetrics; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.base.EChartsConstants; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsPlotGlyph; |
|
||||||
import com.fr.solution.plugin.chart.echarts.pie.plot.RoseType; |
|
||||||
import com.fr.stable.web.Repository; |
|
||||||
|
|
||||||
import java.text.DecimalFormat; |
|
||||||
import java.text.NumberFormat; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
@EnableMetrics |
|
||||||
public class EChartsPiePlotGlyph extends EChartsPlotGlyph { |
|
||||||
|
|
||||||
private static final NumberFormat format = new DecimalFormat("##%"); |
|
||||||
|
|
||||||
private RoseType roseType; |
|
||||||
|
|
||||||
public EChartsPiePlotGlyph() { |
|
||||||
this(RoseType.NONE); |
|
||||||
} |
|
||||||
|
|
||||||
public EChartsPiePlotGlyph(RoseType roseType) { |
|
||||||
this.roseType = roseType; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPlotGlyphType() { |
|
||||||
return "EChartsPiePlotGlyph"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getChartType() { |
|
||||||
return "EChartsPie"; |
|
||||||
} |
|
||||||
|
|
||||||
@Focus(id=EChartsConstants.PLUGIN_ID, text = "", source = Original.PLUGIN) |
|
||||||
public JSONArray toSeriesData(Repository repo) throws JSONException { |
|
||||||
JSONArray result = JSONArray.create(); |
|
||||||
int cn = getCategoryCount(); |
|
||||||
String r = "100%"; |
|
||||||
if (cn > 1) { |
|
||||||
r = format.format(1.0 / (cn + 1)); |
|
||||||
} |
|
||||||
for (int c = 0; c < cn; c++) { |
|
||||||
JSONObject wrapper = JSONObject.create(); |
|
||||||
result.put(wrapper); |
|
||||||
wrapper.put("type", "pie"); |
|
||||||
if (cn > 1) { |
|
||||||
wrapper.put("radius", r); |
|
||||||
wrapper.put("center", JSONArray.create().put(format.format(1.0 * c / (cn + 1) + 0.20)).put("55%")); |
|
||||||
} |
|
||||||
wrapper.put("roseType", roseType.toTypeString()); |
|
||||||
wrapper.put("itemStyle", |
|
||||||
JSONObject.create().put("normal", |
|
||||||
JSONObject.create().put("label", |
|
||||||
JSONObject.create().put("formatter", "{c}")))); |
|
||||||
JSONArray data = JSONArray.create(); |
|
||||||
wrapper.put("data", data); |
|
||||||
|
|
||||||
for (int i = 0, len = getSeriesSize(); i < len; i++) { |
|
||||||
DataSeries series = getSeries(i); |
|
||||||
String name = series.getSeriesName(); |
|
||||||
JSONObject item = JSONObject.create(); |
|
||||||
data.put(item); |
|
||||||
item.put("name", name); |
|
||||||
if (series.getDataPointCount() > 0) { |
|
||||||
DataPoint dataPoint = series.getDataPoint(c); |
|
||||||
item.put("value", dataPoint.getValue()); |
|
||||||
wrapper.put("name", dataPoint.getCategoryName()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return result; |
|
||||||
} |
|
||||||
} |
|
@ -1,32 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie.monitor; |
|
||||||
|
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.stable.fun.FunctionHelper; |
|
||||||
import com.fr.stable.fun.impl.AbstractFunctionProcessor; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public class MonitorPie extends AbstractFunctionProcessor { |
|
||||||
|
|
||||||
private static MonitorPie instance = new MonitorPie(); |
|
||||||
|
|
||||||
public static MonitorPie getInstance() { |
|
||||||
return instance; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public int getId() { |
|
||||||
return FunctionHelper.generateFunctionID("com.fr.solution.plugin.chart.echarts.pie"); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getLocaleKey() { |
|
||||||
return "Plugin-ECharts_Pie"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return Inter.getLocText("Plugin-ECharts_Pie"); |
|
||||||
} |
|
||||||
} |
|
@ -1,102 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie.plot; |
|
||||||
|
|
||||||
import com.fr.base.chart.chartdata.ChartData; |
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.chart.chartdata.NormalChartData; |
|
||||||
import com.fr.chart.chartglyph.PlotGlyph; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.plot.EChartsPlot; |
|
||||||
import com.fr.solution.plugin.chart.echarts.pie.glyph.EChartsPiePlotGlyph; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
import com.fr.stable.xml.XMLPrintWriter; |
|
||||||
import com.fr.stable.xml.XMLableReader; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public class EChartsPiePlot extends EChartsPlot { |
|
||||||
|
|
||||||
public static final String PLOT_ID = "EChartsPiePlot"; |
|
||||||
|
|
||||||
|
|
||||||
private RoseType pieType; |
|
||||||
|
|
||||||
public EChartsPiePlot() { |
|
||||||
this(RoseType.NONE); |
|
||||||
} |
|
||||||
|
|
||||||
public EChartsPiePlot(RoseType pieType) { |
|
||||||
this.pieType = pieType; |
|
||||||
} |
|
||||||
|
|
||||||
public RoseType getPieType() { |
|
||||||
return pieType; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public PlotGlyph createPlotGlyph(ChartData chartData) { |
|
||||||
PlotGlyph glyph = new EChartsPiePlotGlyph(pieType ); |
|
||||||
install4PlotGlyph(glyph, chartData); |
|
||||||
return glyph; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPlotID() { |
|
||||||
return PLOT_ID; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean matchPlotType(Plot newPlot) { |
|
||||||
return newPlot instanceof EChartsPiePlot; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public ChartData defaultChartData() { |
|
||||||
return new NormalChartData(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public boolean accept(Class<? extends Plot> obClass) { |
|
||||||
return ComparatorUtils.equals(EChartsPiePlot.class, obClass); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPlotName() { |
|
||||||
return Inter.getLocText("Plugin-ECharts_Pie"); |
|
||||||
} |
|
||||||
|
|
||||||
protected void readPlotXML(XMLableReader reader) { |
|
||||||
super.readPlotXML(reader); |
|
||||||
if (reader.isChildNode()) { |
|
||||||
String tagName = reader.getTagName(); |
|
||||||
|
|
||||||
if (tagName.equals("PieAttr4ECharts")) { |
|
||||||
pieType = RoseType.parse(reader.getAttrAsString("pieType", StringUtils.EMPTY)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void writeXML(XMLPrintWriter writer) { |
|
||||||
super.writeXML(writer); |
|
||||||
writer.startTAG("PieAttr4ECharts"); |
|
||||||
writer.attr("pieType", pieType.toTypeString()); |
|
||||||
writer.end(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean equals(Object ob) { |
|
||||||
return ob instanceof EChartsPiePlot |
|
||||||
&& super.equals(ob) |
|
||||||
&& ComparatorUtils.equals(((EChartsPiePlot) ob).pieType, pieType); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Object clone() throws CloneNotSupportedException { |
|
||||||
EChartsPiePlot cloned = (EChartsPiePlot) super.clone(); |
|
||||||
cloned.pieType = pieType; |
|
||||||
return cloned; |
|
||||||
} |
|
||||||
} |
|
@ -1,102 +1,41 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie.ui; |
package com.fr.solution.plugin.chart.echarts.pie.ui; |
||||||
|
|
||||||
import com.fr.chart.chartattr.Chart; |
|
||||||
import com.fr.chart.chartattr.Plot; |
|
||||||
import com.fr.design.mainframe.chart.gui.type.ChartImagePane; |
import com.fr.design.mainframe.chart.gui.type.ChartImagePane; |
||||||
import com.fr.general.FRLogger; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.base.ECharts; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.ui.AbstractEChartsTypePane; |
import com.fr.solution.plugin.chart.echarts.common.ui.AbstractEChartsTypePane; |
||||||
import com.fr.solution.plugin.chart.echarts.pie.EChartsPie; |
import com.fr.solution.plugin.chart.echarts.pie.EChartsPie; |
||||||
import com.fr.solution.plugin.chart.echarts.pie.plot.EChartsPiePlot; |
import com.fr.solution.plugin.chart.echarts.pie.plot.RoseType; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by richie on 16/1/29. |
* Created by richie on 16/1/29. |
||||||
*/ |
*/ |
||||||
public class EChartsPieChartTypePane extends AbstractEChartsTypePane { |
public class EChartsPieChartTypePane extends AbstractEChartsTypePane<EChartsPie> { |
||||||
/** |
|
||||||
* 弹出框的标题 |
|
||||||
* |
|
||||||
* @return 弹出框的标题 |
|
||||||
*/ |
|
||||||
public String title4PopupWindow() { |
|
||||||
return Inter.getLocText("Plugin-ECharts_Pie"); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 界面是否接受 |
|
||||||
* |
|
||||||
* @param ob 对象是否为chart |
|
||||||
* @return 界面是否接受对象 |
|
||||||
*/ |
|
||||||
public boolean accept(Object ob) { |
|
||||||
return (ob instanceof ECharts) && ((ECharts) ob).getPlot().accept(EChartsPiePlot.class); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
@Override |
||||||
public Chart getDefaultChart() { |
public String[] getIconsOfTypes() { |
||||||
return EChartsPie.charts[0]; |
return new String[]{ |
||||||
|
"/com/fr/solution/plugin/chart/echarts/pie/images/pie_type_none.png", |
||||||
|
"/com/fr/solution/plugin/chart/echarts/pie/images/pie_type_area.png", |
||||||
|
"/com/fr/solution/plugin/chart/echarts/pie/images/pie_type_radius.png", |
||||||
|
}; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void populateBean(Chart chart) { |
public void populateBean(EChartsPie chart) { |
||||||
for (ChartImagePane imagePane : typeDemo) { |
for (ChartImagePane imagePane : typeDemo) { |
||||||
imagePane.isPressing = false; |
imagePane.isPressing = false; |
||||||
} |
} |
||||||
Plot plot = chart.getPlot(); |
typeDemo.get(chart.getRoseType().ordinal()).isPressing = true; |
||||||
typeDemo.get(plot.getDetailType()).isPressing = true; |
|
||||||
checkDemosBackground(); |
checkDemosBackground(); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
/** |
||||||
protected String getPlotTypeID() { |
* 保存界面属性 |
||||||
return EChartsPiePlot.PLOT_ID; |
*/ |
||||||
} |
public void updateBean(EChartsPie chart) { |
||||||
|
for (int i = 0, len = typeDemo.size(); i < len; i++) { |
||||||
@Override |
|
||||||
protected String[] getTypeTipName() { |
|
||||||
return getNamesOfTypes(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String[] getTypeLayoutTipName() { |
|
||||||
return getNamesOfTypes(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Plot getSelectedClonedPlot() { |
|
||||||
EChartsPiePlot newPlot = null; |
|
||||||
Chart[] pieChart = EChartsPie.charts; |
|
||||||
for(int i = 0, len = pieChart.length; i < len; i++){ |
|
||||||
if (typeDemo.get(i).isPressing) { |
if (typeDemo.get(i).isPressing) { |
||||||
newPlot = pieChart[i].getPlot(); |
chart.setRoseType(RoseType.values()[i]); |
||||||
} |
|
||||||
} |
} |
||||||
|
|
||||||
Plot cloned = null; |
|
||||||
try { |
|
||||||
cloned = (Plot)newPlot.clone(); |
|
||||||
} catch (CloneNotSupportedException e) { |
|
||||||
FRLogger.getLogger().error("Error In ColumnChart"); |
|
||||||
} |
|
||||||
return cloned; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String[] getIconsOfTypes() { |
|
||||||
return new String[]{ |
|
||||||
"/com/fr/solution/plugin/chart/echarts/pie/images/pie_type_none.png", |
|
||||||
"/com/fr/solution/plugin/chart/echarts/pie/images/pie_type_area.png", |
|
||||||
"/com/fr/solution/plugin/chart/echarts/pie/images/pie_type_radius.png", |
|
||||||
}; |
|
||||||
} |
} |
||||||
|
|
||||||
@Override |
|
||||||
public String[] getNamesOfTypes() { |
|
||||||
return new String[]{ |
|
||||||
"Normal", |
|
||||||
"Area", |
|
||||||
"Redius" |
|
||||||
}; |
|
||||||
} |
} |
||||||
} |
} |
@ -1,14 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie.ui; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.ui.data.AbstractEChartsReportDataContentPane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public class EChartsPieReportDataContentPane extends AbstractEChartsReportDataContentPane { |
|
||||||
|
|
||||||
public EChartsPieReportDataContentPane(ChartDataPane parent) { |
|
||||||
super(parent); |
|
||||||
} |
|
||||||
} |
|
@ -1,14 +0,0 @@ |
|||||||
package com.fr.solution.plugin.chart.echarts.pie.ui; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.chart.gui.ChartDataPane; |
|
||||||
import com.fr.solution.plugin.chart.echarts.common.ui.data.AbstractEChartsTableDataContentPane; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by richie on 16/2/18. |
|
||||||
*/ |
|
||||||
public class EChartsPieTableDataContentPane extends AbstractEChartsTableDataContentPane { |
|
||||||
|
|
||||||
public EChartsPieTableDataContentPane(ChartDataPane parent) { |
|
||||||
super(parent); |
|
||||||
} |
|
||||||
} |
|
@ -1,47 +1,15 @@ |
|||||||
/** |
/** |
||||||
* Created by richie on 16/1/29. |
* Created by richie on 16/1/29. |
||||||
*/ |
*/ |
||||||
EChartsFactory = function(options, $dom) { |
Van.FRChartBridge.EChartsFactory = Van.FRChartBridge.AbstractChart.extend({ |
||||||
this.options = options; |
|
||||||
this.$dom = $dom; |
|
||||||
this.chartID = options.chartID; |
|
||||||
this.autoRefreshTime = options.autoRefreshTime || 0; |
|
||||||
|
|
||||||
this.width = options.width || $dom.width();// 补充从dom获取.
|
_init: function (dom, chartAttr) { |
||||||
this.height = options.height || $dom.height(); |
if (chartAttr.theme !== 'default') { |
||||||
this.sheetIndex = options.sheetIndex || 0; |
FR.$defaultImport('/com/fr/solution/plugin/chart/echarts/common/web/theme/' + chartAttr.theme + '.js'); |
||||||
this.ecName = options.ecName || ''; |
|
||||||
|
|
||||||
FR.Chart.WebUtils._installChart(this, this.chartID); |
|
||||||
}; |
|
||||||
|
|
||||||
EChartsFactory.prototype = { |
|
||||||
|
|
||||||
constructor : EChartsFactory, |
|
||||||
|
|
||||||
inits : function() { |
|
||||||
debugger; |
|
||||||
var ct = this.options.chartAttr; |
|
||||||
if (ct.theme != 'default') { |
|
||||||
FR.$defaultImport('/com/fr/solution/plugin/chart/echarts/common/web/theme/' + ct.theme + '.js'); |
|
||||||
} |
} |
||||||
this.newCharts = echarts.init(this.$dom[0], EChartsTheme[ct.theme]); |
var chart = echarts.init(dom, EChartsTheme[chartAttr.theme]); |
||||||
this.newCharts.setOption(ct); |
chart.setOption(chartAttr); |
||||||
}, |
return chart; |
||||||
|
|
||||||
resize : function() { |
|
||||||
this.newCharts.resize(); |
|
||||||
}, |
|
||||||
refresh:function() { |
|
||||||
|
|
||||||
}, |
|
||||||
|
|
||||||
refreshData:function(options){ |
|
||||||
|
|
||||||
}, |
|
||||||
|
|
||||||
//数据监控的刷新方式
|
|
||||||
setData:function(options, aimation){ |
|
||||||
|
|
||||||
} |
} |
||||||
}; |
|
||||||
|
}); |
Loading…
Reference in new issue