Browse Source

Merge branch 'master' of shine/demo-show-echarts into master

master
richie 5 years ago committed by Gogs
parent
commit
b6685744ed
  1. 19
      document/echarts.md
  2. 53
      document/echarts_develop.md
  3. 1
      document/echarts_plot.md
  4. 26
      document/echarts_type_pane.md
  5. 9
      plugin.xml
  6. 158
      src/main/java/com/fr/solution/plugin/chart/echarts/common/base/AbstractECharts.java
  7. 19
      src/main/java/com/fr/solution/plugin/chart/echarts/common/base/AbstractEChartsType.java
  8. 168
      src/main/java/com/fr/solution/plugin/chart/echarts/common/base/ECharts.java
  9. 19
      src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsMoreNameCDDefinition.java
  10. 27
      src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsNormalChartData.java
  11. 17
      src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsNormalReportDataDefinition.java
  12. 19
      src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsOneValueCDDefinition.java
  13. 26
      src/main/java/com/fr/solution/plugin/chart/echarts/common/data/NormalEChartsColumnFieldCollection.java
  14. 53
      src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsGlyph.java
  15. 38
      src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsLegendGlyph.java
  16. 30
      src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsPlotGlyph.java
  17. 30
      src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsTitleGlyph.java
  18. 26
      src/main/java/com/fr/solution/plugin/chart/echarts/common/legend/EChartsLegend.java
  19. 43
      src/main/java/com/fr/solution/plugin/chart/echarts/common/plot/EChartsPlot.java
  20. 6
      src/main/java/com/fr/solution/plugin/chart/echarts/common/theme/EChartsTheme.java
  21. 26
      src/main/java/com/fr/solution/plugin/chart/echarts/common/title/EChartsTitle.java
  22. 7
      src/main/java/com/fr/solution/plugin/chart/echarts/common/tooltip/EChartsTooltip.java
  23. 82
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/AbstractEChartsTypePane.java
  24. 35
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/AbstractEChartsTypeUI.java
  25. 30
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/AbstractIndependentEChartsUI.java
  26. 11
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsLegendPane.java
  27. 41
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsStylePane.java
  28. 15
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsThemePane.java
  29. 15
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTitlePane.java
  30. 15
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTooltipPane.java
  31. 14
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsReportDataContentPane.java
  32. 14
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsTableDataContentPane.java
  33. 50
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/NormalEChartsCellDataPane.java
  34. 52
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/NormalEChartsDataSetPane.java
  35. 36
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/filter/NewDataFilterPane.java
  36. 159
      src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/series/NewSeriesTypeUsePane.java
  37. 155
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPie.java
  38. 27
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPieType.java
  39. 43
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPieTypeUI.java
  40. 37
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPieUI.java
  41. 88
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/glyph/EChartsPiePlotGlyph.java
  42. 32
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/monitor/MonitorPie.java
  43. 102
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/plot/EChartsPiePlot.java
  44. 97
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieChartTypePane.java
  45. 14
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieReportDataContentPane.java
  46. 14
      src/main/java/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieTableDataContentPane.java
  47. 50
      src/main/resources/com/fr/solution/plugin/chart/echarts/common/web/echarts.bridge.js
  48. 1039
      tpl/echarts.frm

19
document/echarts.md

@ -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端
`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中相关配置
`protected void readChartXML(XMLableReader reader)`
// 各种设置信息保存到xml文件中
// 各种设置信息保存到xml文件中,基本数据类型可重写readAttr
`public void writeXML(XMLPrintWriter writer)`

53
document/echarts_develop.md

@ -1,61 +1,62 @@
# 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接口或者其子类的类,都必须要实现相等的判断方法,否者界面设计变化时无法正确检测到属性变化
`public boolean equals(Object ob)`
例如:ECharts,EChartsTooltip等
例如:AbstractECharts,EChartsTooltip等

1
document/echarts_plot.md

@ -1 +0,0 @@
# EChartsPlot类介绍

26
document/echarts_type_pane.md

@ -1,29 +1,17 @@
# AbstractEChartsTypePane子类介绍
# AbstractEChartsTypePane子类介绍:
具有子类型的图表,都需要继承该类以实现各种子类型选择以及切换.具体实现可以参考`EChartsPieChartTypePane`.
需要实现几个重要的方法
// 该选择界面能收的图表类型
`public boolean accept(Object ob)`
// 默认选中的图表
`public Chart getDefaultChart()`
// 图表选择界面读取并展现
`public void populateBean(Chart chart)`
// 获取选中的图表类型
`public Plot getSelectedClonedPlot()`
// 图表各种子类型的图标
`public String[] getIconsOfTypes()`
// 图表各种子类型的名字
// 图表选择界面展现图表属性
`public void populateBean(T chart)`
// 图表选择界面保存图表属性
`public String[] getNamesOfTypes()`
`public void updateBean(T chart)`

9
plugin.xml

@ -4,12 +4,13 @@
<main-package>com.fr.solution.plugin</main-package>
<name><![CDATA[ECharts图表]]></name>
<active>yes</active>
<version>3.1</version>
<version>4.0</version>
<env-version>10.0</env-version>
<jartime>2018-10-01</jartime>
<vendor>author</vendor>
<description><![CDATA[ECharts图表。]]></description>
<change-notes><![CDATA[
<p>[2019-10-24]适配10.0图表相关接口重构</p>
<p>[2016-02-18]饼图(支持多分类饼图)</p>
<p>[2016-03-03]增加国际化支持(美国英语)</p>
<p>[2016-05-28]兼容最新的API升级</p>
@ -20,13 +21,13 @@
<JavaScriptFileHandler class="com.fr.solution.plugin.chart.echarts.common.EChartsFileLoader"/>
</extra-core>
<extra-chart>
<IndependentChartProvider class="com.fr.solution.plugin.chart.echarts.pie.EChartsPie"
<IndependentChartProvider class="com.fr.solution.plugin.chart.echarts.pie.EChartsPieType"
plotID="EChartsPiePlot"/>
</extra-chart>
<extra-chart-designer>
<IndependentChartUIProvider class="com.fr.solution.plugin.chart.echarts.pie.EChartsPieUI"
<IndependentChartUIProvider class="com.fr.solution.plugin.chart.echarts.pie.EChartsPieTypeUI"
plotID="EChartsPiePlot"/>
</extra-chart-designer>
<function-recorder class="com.fr.solution.plugin.chart.echarts.pie.glyph.EChartsPiePlotGlyph"/>
<function-recorder class="com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts"/>
</plugin>

158
src/main/java/com/fr/solution/plugin/chart/echarts/common/base/AbstractECharts.java

@ -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;
}
}

19
src/main/java/com/fr/solution/plugin/chart/echarts/common/base/AbstractIndependentEChartsProvider.java → src/main/java/com/fr/solution/plugin/chart/echarts/common/base/AbstractEChartsType.java

@ -1,12 +1,13 @@
package com.fr.solution.plugin.chart.echarts.common.base;
import com.fr.chart.fun.impl.AbstractIndependentChartProviderWithAPILevel;
import com.fr.chart.impl.AbstractChartType;
/**
* Created by richie on 16/1/29.
* @author shine
* @version 10.0
* Created by shine on 2019/10/23
*/
public abstract class AbstractIndependentEChartsProvider extends AbstractIndependentChartProviderWithAPILevel {
public abstract class AbstractEChartsType extends AbstractChartType {
@Override
public String[] getRequiredJS() {
return new String[]{
@ -15,12 +16,12 @@ public abstract class AbstractIndependentEChartsProvider extends AbstractIndepen
}
@Override
public String getWrapperName() {
return "EChartsFactory";
public String[] getRequiredCss() {
return new String[0];
}
@Override
public int currentAPILevel() {
return CURRENT_API_LEVEL;
public String getWrapperName() {
return "EChartsFactory";
}
}
}

168
src/main/java/com/fr/solution/plugin/chart/echarts/common/base/ECharts.java

@ -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);
}
}

19
src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsMoreNameCDDefinition.java

@ -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;
}
}

27
src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsNormalChartData.java

@ -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() {
//新的图表数据不在这里处理大数据
//画图的时候处理:折线图相同像素点只画一个,其他图表有配置是否采用大数据模式。
}
}

17
src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsNormalReportDataDefinition.java

@ -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();
}
}

19
src/main/java/com/fr/solution/plugin/chart/echarts/common/data/EChartsOneValueCDDefinition.java

@ -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;
}
}

26
src/main/java/com/fr/solution/plugin/chart/echarts/common/data/NormalEChartsColumnFieldCollection.java

@ -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;
}
}

53
src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsGlyph.java

@ -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;
}
}

38
src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsLegendGlyph.java

@ -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;
}
}

30
src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsPlotGlyph.java

@ -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;
}

30
src/main/java/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsTitleGlyph.java

@ -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;
}
}

26
src/main/java/com/fr/solution/plugin/chart/echarts/common/legend/EChartsLegend.java

@ -1,8 +1,10 @@
package com.fr.solution.plugin.chart.echarts.common.legend;
import com.fr.chart.chartattr.Legend;
import com.fr.chart.chartglyph.LegendItem;
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsLegendGlyph;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.ArrayUtils;
/**
* Created by richie on 16/2/18.
@ -11,14 +13,18 @@ public class EChartsLegend extends Legend {
public static final String XML_TAG = "EChartsLegend";
public EChartsLegendGlyph createLegendGlyph(LegendItem[] items) {
EChartsLegendGlyph resultLegendGlyph = new EChartsLegendGlyph(items);
public static JSONObject createAttributeConfig(Object[] seriesArray) throws JSONException {
JSONObject result = JSONObject.create()
.put("orient", "horizontal")
.put("y", "bottom");
resultLegendGlyph.setFont(getFRFont());
resultLegendGlyph.setGeneralInfo(this);
resultLegendGlyph.setPosition(getPosition());
resultLegendGlyph.setVisible(isLegendVisible());
return resultLegendGlyph;
if (ArrayUtils.isNotEmpty(seriesArray)) {
JSONArray data = JSONArray.create();
result.put("data", data);
for (Object item : seriesArray) {
data.put(item);
}
}
return result;
}
}

43
src/main/java/com/fr/solution/plugin/chart/echarts/common/plot/EChartsPlot.java

@ -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()));
}
}
}
}

6
src/main/java/com/fr/solution/plugin/chart/echarts/common/theme/EChartsTheme.java

@ -54,7 +54,9 @@ public class EChartsTheme implements XMLable {
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
public EChartsTheme clone() throws CloneNotSupportedException {
EChartsTheme result = (EChartsTheme) super.clone();
result.setName(this.getName());
return result;
}
}

26
src/main/java/com/fr/solution/plugin/chart/echarts/common/title/EChartsTitle.java

@ -4,8 +4,8 @@ import com.fr.base.Formula;
import com.fr.base.Utils;
import com.fr.chart.chartattr.Title;
import com.fr.general.GeneralUtils;
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsGlyph;
import com.fr.solution.plugin.chart.echarts.common.glyph.EChartsTitleGlyph;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@ -16,8 +16,7 @@ public class EChartsTitle extends Title {
public static final String XML_TAG = "EChartsTitle";
@Override
public EChartsTitleGlyph createGlyph() {
public JSONObject createAttributeConfig() throws JSONException {
Object text = getTextObject();
String text4Glyph = null;
if(text instanceof Formula) {
@ -28,9 +27,12 @@ public class EChartsTitle extends Title {
} else {
text4Glyph = GeneralUtils.objectToString(text);
}
EChartsTitleGlyph titleGlyph = new EChartsTitleGlyph(text4Glyph);
titleGlyph.setVisible(isTitleVisible());
return titleGlyph;
JSONObject t = JSONObject.create()
.put("text", text4Glyph)
.put("x", "center");
t.put("show", isTitleVisible());
return t;
}
@Override
@ -52,4 +54,14 @@ public class EChartsTitle extends Title {
writer.startTAG("Attr4ECharts").end();
writer.end();
}
@Override
public EChartsTitle clone() throws CloneNotSupportedException {
return (EChartsTitle) super.clone();
}
@Override
public boolean equals(Object ob) {
return super.equals(ob);
}
}

7
src/main/java/com/fr/solution/plugin/chart/echarts/common/tooltip/EChartsTooltip.java

@ -4,7 +4,6 @@ import com.fr.general.ComparatorUtils;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.stable.StringUtils;
import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
@ -39,7 +38,7 @@ public class EChartsTooltip implements XMLable {
this.format = format;
}
public JSONObject toJSONObject(Repository repo) throws JSONException {
public JSONObject createAttributeConfig() throws JSONException {
JSONObject jo = JSONObject.create();
jo.put("trigger", triggerType.getType());
jo.put("formatter", format);
@ -77,7 +76,7 @@ public class EChartsTooltip implements XMLable {
}
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
public EChartsTooltip clone() throws CloneNotSupportedException {
return (EChartsTooltip) super.clone();
}
}

82
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/AbstractEChartsTypePane.java

@ -1,26 +1,12 @@
package com.fr.solution.plugin.chart.echarts.common.ui;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Legend;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.mainframe.chart.gui.type.ChartImagePane;
import com.fr.general.FRLogger;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.stable.ArrayUtils;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts;
import java.util.ArrayList;
import java.util.List;
public abstract class AbstractEChartsTypePane extends AbstractChartTypePane{
public abstract class AbstractEChartsTypePane<T extends AbstractECharts> extends AbstractChartTypePane<T> {
private static final long serialVersionUID = 7743244512351499265L;
@Override
protected String[] getTypeLayoutPath() {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
@Override
protected String[] getTypeIconPath() {
return getIconsOfTypes();
@ -32,64 +18,12 @@ public abstract class AbstractEChartsTypePane extends AbstractChartTypePane{
*/
public abstract String[] getIconsOfTypes();
/**
* 各种图表子类型的名字,需要和图表的字类型数量一致
* @return 子类型的名字的集合
*/
public abstract String[] getNamesOfTypes();
/**
* 返回选择的图表子类型
* @return 图表类型
*/
public abstract Plot getSelectedClonedPlot();
/**
* 该选择界面能接收的图表类型
* @param ob 待判断的对象
* @return 如果该选择界面能接收,则返回true,否则返回false
*/
public abstract boolean accept(Object ob);
/**
* 保存界面属性
*/
public void updateBean(Chart chart) {
Plot oldPlot = chart.getPlot();
Plot newPlot = getSelectedClonedPlot();
checkTypeChange(oldPlot);
boolean samePlot = accept(chart);
if(typeChanged && samePlot){
//同一中图表切换不同类型
cloneOldPlot2New(oldPlot, newPlot);
chart.setPlot(newPlot);
} else if(!samePlot){
//不同的图表类型切换
chart.setPlot(newPlot);
}
}
protected void checkTypeChange(Plot oldPlot){
for(int i = 0; i < typeDemo.size(); i++){
if(typeDemo.get(i).isPressing && i != oldPlot.getDetailType()){
typeChanged = true;
break;
}
typeChanged = false;
}
@Override
protected String[] getTypeTipName() {
return ChartTypeInterfaceManager.getInstance().getSubName(getPlotID());
}
/**
* 同一个图表 类型之间切换
*/
protected void cloneOldPlot2New(Plot oldPlot, Plot newPlot) {
try {
if (oldPlot.getLegend() != null) {
newPlot.setLegend((Legend) oldPlot.getLegend().clone());
}
} catch (CloneNotSupportedException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
public String title4PopupWindow() {
return ChartTypeInterfaceManager.getInstance().getName(getPlotID());
}
}

35
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/AbstractEChartsTypeUI.java

@ -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());
}
};
}
}

30
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/AbstractIndependentEChartsUI.java

@ -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;
}
}

11
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsLegendPane.java

@ -3,15 +3,16 @@ package com.fr.solution.plugin.chart.echarts.common.ui;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
/**
* Created by richie on 16/2/22.
*/
public class EChartsLegendPane extends BasicScrollPane<ECharts> {
public class EChartsLegendPane extends BasicScrollPane<AbstractECharts> {
public EChartsLegendPane(EChartsStylePane parent) {
@ -24,7 +25,7 @@ public class EChartsLegendPane extends BasicScrollPane<ECharts> {
}
@Override
public void populateBean(ECharts ob) {
public void populateBean(AbstractECharts ob) {
}

41
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsStylePane.java

@ -1,23 +1,25 @@
package com.fr.solution.plugin.chart.echarts.common.ui;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chartx.impl.AbstractOtherPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.util.ArrayList;
import java.util.List;
public class EChartsStylePane extends AbstractChartAttrPane implements UIObserver {
public class EChartsStylePane extends AbstractOtherPane<AbstractECharts> implements UIObserver {
private KindOfTabPane kindOfTabPane;
@ -29,7 +31,7 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve
private AttributeChangeListener listener;
private UIObserverListener uiObserverListener;
private ECharts chart;
private AbstractECharts chart;
public EChartsStylePane(AttributeChangeListener listener) {
this.listener = listener;
@ -89,10 +91,9 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve
return "com/fr/solution/plugin/chart/echarts/images/toolbar_item.png";
}
@Override
public void populate(ChartCollection collection) {
this.chart = (ECharts) collection.getSelectedChart();
public void populate(AbstractECharts chart) {
this.chart = chart;
this.remove(leftContentPane);
initContentPane();
this.removeAttributeChangeListener();
@ -102,8 +103,8 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve
}
@Override
public void update(ChartCollection collection) {
kindOfTabPane.updateBean((ECharts) collection.getSelectedChart());
public void update(AbstractECharts chart) {
kindOfTabPane.updateBean(chart);
}
/**
@ -136,7 +137,7 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve
/**
* 二级tab组件
*/
public class KindOfTabPane extends MultiTabPane<ECharts> {
public class KindOfTabPane extends MultiTabPane<AbstractECharts> {
@Override
protected void initLayout() {
@ -185,7 +186,7 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve
@Override
protected void tabChanged() {
EChartsStylePane.this.removeAttributeChangeListener();
((BasicBeanPane<ECharts>) paneList.get(tabPane.getSelectedIndex())).populateBean(chart);
((BasicBeanPane<AbstractECharts>) paneList.get(tabPane.getSelectedIndex())).populateBean(chart);
EChartsStylePane.this.addAttributeChangeListener(listener);
}
@ -200,25 +201,25 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve
}
@Override
public void populateBean(ECharts ob) {
public void populateBean(AbstractECharts ob) {
if (chart == null || kindOfTabPane.getSelectedIndex() == -1) {
return;
}
((BasicBeanPane<ECharts>) paneList.get(kindOfTabPane.getSelectedIndex())).populateBean(chart);
((BasicBeanPane<AbstractECharts>) paneList.get(kindOfTabPane.getSelectedIndex())).populateBean(chart);
}
@Override
public ECharts updateBean() {
public AbstractECharts updateBean() {
if (chart == null) {
return null;
}
((BasicBeanPane<ECharts>) paneList.get(kindOfTabPane.getSelectedIndex())).updateBean(chart);
((BasicBeanPane<AbstractECharts>) paneList.get(kindOfTabPane.getSelectedIndex())).updateBean(chart);
return chart;
}
@Override
public void updateBean(ECharts ob) {
BasicBeanPane<ECharts> pane = ((BasicBeanPane<ECharts>) paneList.get(kindOfTabPane.getSelectedIndex()));
public void updateBean(AbstractECharts ob) {
BasicBeanPane<AbstractECharts> pane = ((BasicBeanPane<AbstractECharts>) paneList.get(kindOfTabPane.getSelectedIndex()));
pane.updateBean(ob);
}

15
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsThemePane.java

@ -6,16 +6,17 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts;
import com.fr.solution.plugin.chart.echarts.common.theme.EChartsTheme;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by richie on 16/2/22.
*/
public class EChartsThemePane extends BasicScrollPane<ECharts> {
public class EChartsThemePane extends BasicScrollPane<AbstractECharts> {
private static final String[] themes = new String[]{"default", "dark"};
@ -48,7 +49,7 @@ public class EChartsThemePane extends BasicScrollPane<ECharts> {
}
@Override
public void populateBean(ECharts ob) {
public void populateBean(AbstractECharts ob) {
if (ob == null) {
return;
}
@ -59,9 +60,9 @@ public class EChartsThemePane extends BasicScrollPane<ECharts> {
}
@Override
public void updateBean(ECharts ob) {
public void updateBean(AbstractECharts ob) {
if (ob == null) {
ob = new ECharts();
return;
}
EChartsTheme theme = new EChartsTheme();
theme.setName(themeComboBox.getSelectedItem());

15
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTitlePane.java

@ -9,17 +9,18 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.GeneralUtils;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts;
import com.fr.solution.plugin.chart.echarts.common.title.EChartsTitle;
import com.fr.stable.StableUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by richie on 16/2/19.
*/
public class EChartsTitlePane extends BasicScrollPane<ECharts> {
public class EChartsTitlePane extends BasicScrollPane<AbstractECharts> {
private UIButtonGroup<Boolean> showTitle;
@ -54,7 +55,7 @@ public class EChartsTitlePane extends BasicScrollPane<ECharts> {
}
@Override
public void populateBean(ECharts ob) {
public void populateBean(AbstractECharts ob) {
EChartsTitle title = (EChartsTitle) ob.getTitle();
if (title == null) {
return;
@ -68,9 +69,9 @@ public class EChartsTitlePane extends BasicScrollPane<ECharts> {
}
@Override
public void updateBean(ECharts ob) {
public void updateBean(AbstractECharts ob) {
if (ob == null) {
ob = new ECharts();
return;
}
EChartsTitle title = new EChartsTitle();
ob.setTitle(title);

15
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTooltipPane.java

@ -7,17 +7,18 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractECharts;
import com.fr.solution.plugin.chart.echarts.common.tooltip.EChartsTooltip;
import com.fr.solution.plugin.chart.echarts.common.tooltip.TriggerType;
import javax.swing.*;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
/**
* Created by richie on 16/2/19.
*/
public class EChartsTooltipPane extends BasicScrollPane<ECharts> {
public class EChartsTooltipPane extends BasicScrollPane<AbstractECharts> {
private UIDictionaryComboBox<TriggerType> triggerComboBox;
private UITextField formatterTextField;
@ -54,7 +55,7 @@ public class EChartsTooltipPane extends BasicScrollPane<ECharts> {
}
@Override
public void populateBean(ECharts ob) {
public void populateBean(AbstractECharts ob) {
if (ob == null) {
return;
}
@ -67,9 +68,9 @@ public class EChartsTooltipPane extends BasicScrollPane<ECharts> {
}
@Override
public void updateBean(ECharts ob) {
public void updateBean(AbstractECharts ob) {
if (ob == null) {
ob = new ECharts();
return;
}
EChartsTooltip tooltip = new EChartsTooltip();
tooltip.setTriggerType(triggerComboBox.getSelectedItem());

14
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsReportDataContentPane.java

@ -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);
}
}

14
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsTableDataContentPane.java

@ -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);
}
}

50
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/NormalEChartsCellDataPane.java

@ -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;
}
}

52
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/data/NormalEChartsDataSetPane.java

@ -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;
}
}

36
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/filter/NewDataFilterPane.java

@ -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;
}
}

159
src/main/java/com/fr/solution/plugin/chart/echarts/common/ui/series/NewSeriesTypeUsePane.java

@ -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);
}
}
}

155
src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPie.java

@ -1,40 +1,155 @@
package com.fr.solution.plugin.chart.echarts.pie;
import com.fr.chart.chartattr.Chart;
import com.fr.solution.plugin.chart.echarts.common.base.AbstractIndependentEChartsProvider;
import com.fr.solution.plugin.chart.echarts.common.base.ECharts;
import com.fr.solution.plugin.chart.echarts.pie.plot.EChartsPiePlot;
import com.fr.chart.ChartWebParaProvider;
import com.fr.chartx.TwoTuple;
import com.fr.general.ComparatorUtils;
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.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());
private static ECharts createPie(RoseType type) {
EChartsPiePlot plot = new EChartsPiePlot(type);
return new ECharts(plot);
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);
JSONArray result = JSONArray.create();
int cn = aboutCate.getSecond();
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);
for (int i = 0, len = seriesList.size(); i < len; i++) {
if (ComparatorUtils.equals(categoryName, categoryList.get(i))) {
JSONObject item = JSONObject.create();
data.put(item);
item.put("name", seriesList.get(i));
item.put("value", valueList.get(i));
}
}
}
return result;
}
public static ECharts[] charts = new ECharts[] {
createPie(RoseType.NONE),
createPie(RoseType.AREA),
createPie(RoseType.RADIUS),
};
@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
public String getChartName() {
return "Plugin-ECharts_Pie";
public boolean equals(Object ob) {
return ob instanceof EChartsPie
&& ((EChartsPie) ob).getRoseType() == this.getRoseType()
&& super.equals(ob);
}
@Override
public Chart[] getChartTypes() {
return charts;
public int hashCode() {
return super.hashCode() + AssistUtils.hashCode(roseType);
}
@Override
public String getChartImagePath() {
return "com/fr/solution/plugin/chart/echarts/pie/images/pie256.png";
public EChartsPie clone() throws CloneNotSupportedException {
EChartsPie result = (EChartsPie) super.clone();
result.roseType = this.getRoseType();
return result;
}
}

27
src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPieType.java

@ -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);
}
}

43
src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPieTypeUI.java

@ -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";
}
}

37
src/main/java/com/fr/solution/plugin/chart/echarts/pie/EChartsPieUI.java

@ -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";
}
}

88
src/main/java/com/fr/solution/plugin/chart/echarts/pie/glyph/EChartsPiePlotGlyph.java

@ -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;
}
}

32
src/main/java/com/fr/solution/plugin/chart/echarts/pie/monitor/MonitorPie.java

@ -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");
}
}

102
src/main/java/com/fr/solution/plugin/chart/echarts/pie/plot/EChartsPiePlot.java

@ -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;
}
}

97
src/main/java/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieChartTypePane.java

@ -1,102 +1,41 @@
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.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.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.
*/
public class EChartsPieChartTypePane extends AbstractEChartsTypePane {
/**
* 弹出框的标题
*
* @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);
}
public class EChartsPieChartTypePane extends AbstractEChartsTypePane<EChartsPie> {
@Override
public Chart getDefaultChart() {
return EChartsPie.charts[0];
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 void populateBean(Chart chart) {
for(ChartImagePane imagePane : typeDemo) {
public void populateBean(EChartsPie chart) {
for (ChartImagePane imagePane : typeDemo) {
imagePane.isPressing = false;
}
Plot plot = chart.getPlot();
typeDemo.get(plot.getDetailType()).isPressing = true;
typeDemo.get(chart.getRoseType().ordinal()).isPressing = true;
checkDemosBackground();
}
@Override
protected String getPlotTypeID() {
return EChartsPiePlot.PLOT_ID;
}
@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){
newPlot = pieChart[i].getPlot();
/**
* 保存界面属性
*/
public void updateBean(EChartsPie chart) {
for (int i = 0, len = typeDemo.size(); i < len; i++) {
if (typeDemo.get(i).isPressing) {
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"
};
}
}

14
src/main/java/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieReportDataContentPane.java

@ -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);
}
}

14
src/main/java/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieTableDataContentPane.java

@ -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);
}
}

50
src/main/resources/com/fr/solution/plugin/chart/echarts/common/web/echarts.bridge.js

@ -1,47 +1,15 @@
/**
* Created by richie on 16/1/29.
*/
EChartsFactory = function(options, $dom) {
this.options = options;
this.$dom = $dom;
this.chartID = options.chartID;
this.autoRefreshTime = options.autoRefreshTime || 0;
Van.FRChartBridge.EChartsFactory = Van.FRChartBridge.AbstractChart.extend({
this.width = options.width || $dom.width();// 补充从dom获取.
this.height = options.height || $dom.height();
this.sheetIndex = options.sheetIndex || 0;
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');
_init: function (dom, chartAttr) {
if (chartAttr.theme !== 'default') {
FR.$defaultImport('/com/fr/solution/plugin/chart/echarts/common/web/theme/' + chartAttr.theme + '.js');
}
this.newCharts = echarts.init(this.$dom[0], EChartsTheme[ct.theme]);
this.newCharts.setOption(ct);
},
resize : function() {
this.newCharts.resize();
},
refresh:function() {
},
refreshData:function(options){
},
//数据监控的刷新方式
setData:function(options, aimation){
var chart = echarts.init(dom, EChartsTheme[chartAttr.theme]);
chart.setOption(chartAttr);
return chart;
}
};
});

1039
tpl/echarts.frm

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save