Browse Source

echarts基本功能

pull/1/head
richie 9 years ago
parent
commit
a08aa70aca
  1. 39
      src/com/fr/solution/plugin/chart/echarts/base/NewChart.java
  2. 25
      src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java
  3. 3
      src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java
  4. 4
      src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java
  5. 2
      src/com/fr/solution/plugin/chart/echarts/glyph/NewLegendGlyph.java
  6. 2
      src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java
  7. 9
      src/com/fr/solution/plugin/chart/echarts/glyph/NewTitleGlyph.java
  8. 24
      src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java
  9. 39
      src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java
  10. 16
      src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java

39
src/com/fr/solution/plugin/chart/echarts/base/NewChart.java

@ -3,7 +3,17 @@ package com.fr.solution.plugin.chart.echarts.base;
import com.fr.base.chart.BaseChartGlyph; import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.ChartData; import com.fr.base.chart.chartdata.ChartData;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.solution.plugin.chart.echarts.glyph.NewGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.NewTitleGlyph;
import com.fr.solution.plugin.chart.echarts.plot.NewPlot;
import com.fr.solution.plugin.chart.echarts.title.NewTitle;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader;
/** /**
* Created by richie on 16/1/29. * Created by richie on 16/1/29.
@ -13,11 +23,13 @@ public class NewChart extends Chart {
public NewChart() { public NewChart() {
setWrapperName("EChartsFactory"); setWrapperName("EChartsFactory");
setTitle(new NewTitle());
} }
public NewChart(NewPlot plot) { public NewChart(NewPlot plot) {
super(plot); super(plot);
setWrapperName("EChartsFactory"); setWrapperName("EChartsFactory");
setTitle(new NewTitle());
} }
@Override @Override
@ -26,9 +38,16 @@ public class NewChart extends Chart {
glyph.setGeneralInfo(this); glyph.setGeneralInfo(this);
NewPlot newPlot = (NewPlot) getPlot(); NewPlot newPlot = (NewPlot) getPlot();
if (newPlot != null) { if (newPlot != null) {
glyph.setLegendGlyph(newPlot.createChartLegendGlyph(chartData)); PlotGlyph plotGlyph = newPlot.createPlotGlyph(chartData);
glyph.setTitleGlyph(newPlot.createChartTitleGlyph(chartData)); NewLegendGlyph legendGlyph = newPlot.createLegendGlyph(plotGlyph);
glyph.setLegendGlyph(legendGlyph);
} }
NewTitle title = (NewTitle)getTitle();
if (title != null) {
NewTitleGlyph titleGlyph = title.createGlyph();
glyph.setTitleGlyph(titleGlyph);
}
glyph.setWrapperName(getWrapperName()); glyph.setWrapperName(getWrapperName());
glyph.setChartImagePath(getImagePath()); glyph.setChartImagePath(getImagePath());
glyph.setRequiredJS(getRequiredJS()); glyph.setRequiredJS(getRequiredJS());
@ -45,4 +64,20 @@ public class NewChart extends Chart {
public boolean accept(Class<? extends Chart> obClass){ public boolean accept(Class<? extends Chart> obClass){
return ComparatorUtils.equals(NewChart.class, obClass); return ComparatorUtils.equals(NewChart.class, obClass);
} }
@Override
protected void readChartXML(XMLableReader reader) {
if (reader.isChildNode()) {
String tmpNodeName = reader.getTagName();
if (tmpNodeName.equals(NewTitle.XML_TAG)) {
setTitle(new NewTitle());
reader.readXMLObject(getTitle());
} else if (tmpNodeName.equals(Plot.XML_TAG)) {
setPlot((Plot) GeneralXMLTools.readXMLable(reader));
}
}
}
} }

25
src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java

@ -1,25 +0,0 @@
package com.fr.solution.plugin.chart.echarts.base;
import com.fr.base.chart.chartdata.ChartData;
import com.fr.chart.chartattr.Plot;
import com.fr.general.ComparatorUtils;
/**
* Created by richie on 16/2/2.
*/
public abstract class NewPlot extends Plot {
public boolean accept(Class<? extends Plot> obClass) {
return ComparatorUtils.equals(NewPlot.class, obClass);
}
public NewTitleGlyph createChartTitleGlyph(ChartData chartData) {
return new NewTitleGlyph("iPhone", "iPhone");
}
public NewLegendGlyph createChartLegendGlyph(ChartData chartData) {
return new NewLegendGlyph();
}
}

3
src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java

@ -3,11 +3,10 @@ package com.fr.solution.plugin.chart.echarts.core.map;
import com.fr.base.chart.chartdata.ChartData; import com.fr.base.chart.chartdata.ChartData;
import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.NormalChartData; import com.fr.chart.chartdata.NormalChartData;
import com.fr.chart.chartglyph.LegendGlyph;
import com.fr.chart.chartglyph.PlotGlyph; import com.fr.chart.chartglyph.PlotGlyph;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.solution.plugin.chart.echarts.base.NewPlot; import com.fr.solution.plugin.chart.echarts.plot.NewPlot;
import com.fr.stable.fun.FunctionProcessor; import com.fr.stable.fun.FunctionProcessor;
/** /**

4
src/com/fr/solution/plugin/chart/echarts/base/NewGlyph.java → src/com/fr/solution/plugin/chart/echarts/glyph/NewGlyph.java

@ -1,9 +1,11 @@
package com.fr.solution.plugin.chart.echarts.base; package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.ChartGlyph; import com.fr.chart.chartglyph.ChartGlyph;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.glyph.NewTitleGlyph;
import com.fr.stable.web.Repository; import com.fr.stable.web.Repository;
/** /**

2
src/com/fr/solution/plugin/chart/echarts/base/NewLegendGlyph.java → src/com/fr/solution/plugin/chart/echarts/glyph/NewLegendGlyph.java

@ -1,4 +1,4 @@
package com.fr.solution.plugin.chart.echarts.base; package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.LegendGlyph; import com.fr.chart.chartglyph.LegendGlyph;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;

2
src/com/fr/solution/plugin/chart/echarts/base/NewSeriesGlyph.java → src/com/fr/solution/plugin/chart/echarts/glyph/NewSeriesGlyph.java

@ -1,4 +1,4 @@
package com.fr.solution.plugin.chart.echarts.base; package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.ChartGlyph; import com.fr.chart.chartglyph.ChartGlyph;

9
src/com/fr/solution/plugin/chart/echarts/base/NewTitleGlyph.java → src/com/fr/solution/plugin/chart/echarts/glyph/NewTitleGlyph.java

@ -1,6 +1,6 @@
package com.fr.solution.plugin.chart.echarts.base; package com.fr.solution.plugin.chart.echarts.glyph;
import com.fr.chart.chartglyph.ChartGlyph; import com.fr.chart.chartglyph.TitleGlyph;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.web.Repository; import com.fr.stable.web.Repository;
@ -8,8 +8,11 @@ import com.fr.stable.web.Repository;
/** /**
* Created by richie on 16/2/2. * Created by richie on 16/2/2.
*/ */
public class NewTitleGlyph extends ChartGlyph { public class NewTitleGlyph extends TitleGlyph {
public NewTitleGlyph() {
}
public NewTitleGlyph(String title, String subTitle) { public NewTitleGlyph(String title, String subTitle) {

24
src/com/fr/solution/plugin/chart/echarts/legend/NewLegend.java

@ -0,0 +1,24 @@
package com.fr.solution.plugin.chart.echarts.legend;
import com.fr.chart.chartattr.Legend;
import com.fr.solution.plugin.chart.echarts.glyph.NewLegendGlyph;
/**
* Created by richie on 16/2/18.
*/
public class NewLegend extends Legend {
public static final String XML_TAG = "NewLegend";
public NewLegendGlyph createLegendGlyph() {
NewLegendGlyph resultLegendGlyph = new NewLegendGlyph();
resultLegendGlyph.setFont(getFRFont());
resultLegendGlyph.setGeneralInfo(this);
resultLegendGlyph.setPosition(getPosition());
resultLegendGlyph.setVisible(isLegendVisible());
return resultLegendGlyph;
}
}

39
src/com/fr/solution/plugin/chart/echarts/plot/NewPlot.java

@ -0,0 +1,39 @@
package com.fr.solution.plugin.chart.echarts.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.glyph.NewLegendGlyph;
import com.fr.solution.plugin.chart.echarts.legend.NewLegend;
import com.fr.stable.xml.XMLableReader;
/**
* Created by richie on 16/2/2.
*/
public abstract class NewPlot extends Plot {
public NewPlot() {
setLegend(new NewLegend());
}
public boolean accept(Class<? extends Plot> obClass) {
return ComparatorUtils.equals(NewPlot.class, obClass);
}
@Override
public NewLegendGlyph createLegendGlyph(PlotGlyph plotGlyph) {
NewLegend legend = (NewLegend) getLegend();
return legend.createLegendGlyph();
}
protected void readPlotXML(XMLableReader reader){
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if (NewLegend.XML_TAG.equals(tagName)) {
setLegend((Legend)reader.readXMLObject(new NewLegend()));
}
}
}
}

16
src/com/fr/solution/plugin/chart/echarts/title/NewTitle.java

@ -0,0 +1,16 @@
package com.fr.solution.plugin.chart.echarts.title;
import com.fr.chart.chartattr.Title;
import com.fr.solution.plugin.chart.echarts.glyph.NewTitleGlyph;
/**
* Created by richie on 16/2/18.
*/
public class NewTitle extends Title {
public static final String XML_TAG = "NewTitle";
@Override
public NewTitleGlyph createGlyph() {
return new NewTitleGlyph();
}
}
Loading…
Cancel
Save