Browse Source

空指针错误

pull/1/head
richie 9 years ago
parent
commit
b5cb987f3e
  1. 5
      src/com/fr/solution/plugin/chart/echarts/base/NewChart.java
  2. 28
      src/com/fr/solution/plugin/chart/echarts/base/NewGlyph.java
  3. 16
      src/com/fr/solution/plugin/chart/echarts/base/NewLegendGlyph.java
  4. 2
      src/com/fr/solution/plugin/chart/echarts/base/NewPlot.java
  5. 9
      src/com/fr/solution/plugin/chart/echarts/base/NewTitleGlyph.java

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

@ -10,22 +10,21 @@ import com.fr.general.ComparatorUtils;
*/
public class NewChart extends Chart {
private NewPlot newPlot;
public NewChart() {
setWrapperName("EChartsFactory");
}
public NewChart(NewPlot plot) {
super(plot);
setWrapperName("EChartsFactory");
this.newPlot = plot;
}
@Override
public BaseChartGlyph createGlyph(ChartData chartData) {
NewGlyph glyph = new NewGlyph();
glyph.setGeneralInfo(this);
NewPlot newPlot = (NewPlot) getPlot();
if (newPlot != null) {
glyph.setLegendGlyph(newPlot.createChartLegendGlyph(chartData));
glyph.setTitleGlyph(newPlot.createChartTitleGlyph(chartData));

28
src/com/fr/solution/plugin/chart/echarts/base/NewGlyph.java

@ -32,41 +32,29 @@ public class NewGlyph extends ChartGlyph {
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {
JSONObject jo = new JSONObject();
jo.put("title", createTitle(repo));
// if (titleGlyph != null) {
// jo.put("title", titleGlyph.toJSONObject(repo));
// }
//jo.put("title", createTitle(repo));
if (titleGlyph != null) {
jo.put("title", titleGlyph.toJSONObject(repo));
}
jo.put("tooltip", createTooltip(repo));
jo.put("legend", createLegend(repo));
// jo.put("legend", createLegend(repo));
// if (legendGlyph != null) {
// jo.put("legend", legendGlyph.toJSONObject(repo));
// }
if (legendGlyph != null) {
jo.put("legend", legendGlyph.toJSONObject(repo));
}
jo.put("dataRange", createDataRange(repo));
jo.put("series", createSeries(repo));
return jo;
}
private JSONObject createTitle(Repository repo) throws JSONException {
return JSONObject.create()
.put("text", "iPhoneÏúÁ¿")
.put("subtext", "´¿ÊôÐé¹¹")
.put("x", "center");
}
private JSONObject createTooltip(Repository repo) throws JSONException {
return JSONObject.create()
.put("trigger", "item");
}
private JSONObject createLegend(Repository repo) throws JSONException {
return JSONObject.create()
.put("orient", "vertical")
.put("x", "left")
.put("data", JSONArray.create().put("iPhone3").put("iPhone4").put("iPhone5"));
}
private JSONObject createDataRange(Repository repo) throws JSONException {
return JSONObject.create()

16
src/com/fr/solution/plugin/chart/echarts/base/NewLegendGlyph.java

@ -1,9 +1,25 @@
package com.fr.solution.plugin.chart.echarts.base;
import com.fr.chart.chartglyph.LegendGlyph;
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/2.
*/
public class NewLegendGlyph extends LegendGlyph {
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {
return createLegend(repo);
}
private JSONObject createLegend(Repository repo) throws JSONException {
return JSONObject.create()
.put("orient", "vertical")
.put("x", "left")
.put("data", JSONArray.create().put("iPhone3").put("iPhone4").put("iPhone5"));
}
}

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

@ -13,6 +13,8 @@ public abstract class NewPlot extends Plot {
return ComparatorUtils.equals(NewPlot.class, obClass);
}
public NewTitleGlyph createChartTitleGlyph(ChartData chartData) {
return new NewTitleGlyph("iPhone", "iPhone");
}

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

@ -17,7 +17,14 @@ public class NewTitleGlyph extends ChartGlyph {
@Override
public JSONObject toJSONObject(Repository repo) throws JSONException {
return super.toJSONObject(repo);
return createTitle(repo);
}
private JSONObject createTitle(Repository repo) throws JSONException {
return JSONObject.create()
.put("text", "iPhoneÏúÁ¿")
.put("subtext", "´¿ÊôÐé¹¹")
.put("x", "center");
}
}

Loading…
Cancel
Save