diff --git a/src/com/fr/solution/plugin/chart/echarts/ChineseMap.java b/src/com/fr/solution/plugin/chart/echarts/ChineseMap.java index 484f0ef..108f93f 100644 --- a/src/com/fr/solution/plugin/chart/echarts/ChineseMap.java +++ b/src/com/fr/solution/plugin/chart/echarts/ChineseMap.java @@ -3,7 +3,7 @@ package com.fr.solution.plugin.chart.echarts; import com.fr.chart.chartattr.Chart; import com.fr.general.Inter; import com.fr.solution.plugin.chart.echarts.base.AbstractIndependentEChartsProvider; -import com.fr.solution.plugin.chart.echarts.base.ECharts; +import com.fr.solution.plugin.chart.echarts.base.NewChart; import com.fr.solution.plugin.chart.echarts.core.map.ChineseMapPlot; /** @@ -11,12 +11,12 @@ import com.fr.solution.plugin.chart.echarts.core.map.ChineseMapPlot; */ public class ChineseMap extends AbstractIndependentEChartsProvider { - private static ECharts createChineseMap() { + private static NewChart createChineseMap() { ChineseMapPlot plot = new ChineseMapPlot(); - return new ECharts(plot); + return new NewChart(plot); } - public static ECharts[] charts = new ECharts[] { + public static NewChart[] charts = new NewChart[] { createChineseMap() }; diff --git a/src/com/fr/solution/plugin/chart/echarts/base/EChartsGlyph.java b/src/com/fr/solution/plugin/chart/echarts/base/EChartsGlyph.java deleted file mode 100644 index 041c974..0000000 --- a/src/com/fr/solution/plugin/chart/echarts/base/EChartsGlyph.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fr.solution.plugin.chart.echarts.base; - -import com.fr.chart.chartglyph.ChartGlyph; -import com.fr.json.JSONException; -import com.fr.json.JSONObject; -import com.fr.stable.web.Repository; - -/** - * Created by richie on 16/1/29. - */ -public class EChartsGlyph extends ChartGlyph { - - @Override - public JSONObject toJSONObject(Repository repo) throws JSONException { - return new JSONObject(); - } -} diff --git a/src/com/fr/solution/plugin/chart/echarts/base/ECharts.java b/src/com/fr/solution/plugin/chart/echarts/base/NewChart.java similarity index 60% rename from src/com/fr/solution/plugin/chart/echarts/base/ECharts.java rename to src/com/fr/solution/plugin/chart/echarts/base/NewChart.java index 5331f34..1a83e86 100644 --- a/src/com/fr/solution/plugin/chart/echarts/base/ECharts.java +++ b/src/com/fr/solution/plugin/chart/echarts/base/NewChart.java @@ -9,20 +9,27 @@ import com.fr.general.ComparatorUtils; /** * Created by richie on 16/1/29. */ -public class ECharts extends Chart { +public class NewChart extends Chart { - public ECharts() { + public NewChart() { setWrapperName("EChartsFactory"); } - public ECharts(Plot plot) { + public NewChart(Plot plot) { setPlot(plot); setWrapperName("EChartsFactory"); } @Override public BaseChartGlyph createGlyph(ChartData chartData) { - return super.createGlyph(chartData); + NewChartGlyph glyph = new NewChartGlyph(); + glyph.setGeneralInfo(this); + glyph.setWrapperName(wrapperName); + glyph.setChartImagePath(getImagePath()); + glyph.setRequiredJS(getRequiredJS()); + glyph.setJSDraw(isJSDraw()); + + return glyph; } /** @@ -31,6 +38,6 @@ public class ECharts extends Chart { * @return 是否是obClass对象 */ public boolean accept(Class obClass){ - return ComparatorUtils.equals(ECharts.class, obClass); + return ComparatorUtils.equals(NewChart.class, obClass); } } diff --git a/src/com/fr/solution/plugin/chart/echarts/base/NewChartGlyph.java b/src/com/fr/solution/plugin/chart/echarts/base/NewChartGlyph.java new file mode 100644 index 0000000..f02cf19 --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/base/NewChartGlyph.java @@ -0,0 +1,80 @@ +package com.fr.solution.plugin.chart.echarts.base; + +import com.fr.chart.chartglyph.ChartGlyph; +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/1/29. + */ +public class NewChartGlyph extends ChartGlyph { + + @Override + public JSONObject toJSONObject(Repository repo) throws JSONException { + JSONObject jo = new JSONObject(); + jo.put("title", createTitle(repo)); + jo.put("tooltip", createTooltip(repo)); + jo.put("legend", createLegend(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() + .put("min", 0) + .put("max", 2500) + .put("x", "left") + .put("y", "bottom") + .put("text", JSONArray.create().put("高").put("低")); + } + + private JSONArray createSeries(Repository repo) throws JSONException { + JSONArray series = JSONArray.create(); + + series.put(JSONObject.create() + .put("name", "iPhone3") + .put("type", "map") + .put("mapType", "china") + .put("data", JSONArray.create().put(JSONObject.create().put("name", "北京").put("value", 20))) + ); + + series.put(JSONObject.create() + .put("name", "iPhone4") + .put("type", "map") + .put("mapType", "china") + .put("data", JSONArray.create().put(JSONObject.create().put("name", "江苏").put("value", 20))) + ); + + series.put(JSONObject.create() + .put("name", "iPhone5") + .put("type", "map") + .put("mapType", "china") + .put("data", JSONArray.create().put(JSONObject.create().put("name", "四川").put("value", 20))) + ); + + return series; + } + +} diff --git a/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapFunctionProcessor.java b/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapFunctionProcessor.java index 757d57a..112f525 100644 --- a/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapFunctionProcessor.java +++ b/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapFunctionProcessor.java @@ -2,6 +2,7 @@ package com.fr.solution.plugin.chart.echarts.core.map; import com.fr.general.Inter; import com.fr.stable.fun.FunctionHelper; +import com.fr.stable.fun.FunctionProcessor; import com.fr.stable.fun.impl.AbstractFunctionProcessor; /** @@ -9,6 +10,7 @@ import com.fr.stable.fun.impl.AbstractFunctionProcessor; */ public class ChineseMapFunctionProcessor extends AbstractFunctionProcessor { + public static FunctionProcessor MAP = new ChineseMapFunctionProcessor(); @Override public int getId() { diff --git a/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java b/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java index 78e1def..90e4a48 100644 --- a/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java +++ b/src/com/fr/solution/plugin/chart/echarts/core/map/ChineseMapPlot.java @@ -37,7 +37,7 @@ public class ChineseMapPlot extends Plot { @Override public FunctionProcessor getFunctionToRecord() { - return FunctionProcessor.EMAIL; + return ChineseMapFunctionProcessor.MAP; } public boolean accept(Class obClass) { diff --git a/src/com/fr/solution/plugin/chart/echarts/web/echarts.bridge.js b/src/com/fr/solution/plugin/chart/echarts/web/echarts.bridge.js index d977ca8..c9027b8 100644 --- a/src/com/fr/solution/plugin/chart/echarts/web/echarts.bridge.js +++ b/src/com/fr/solution/plugin/chart/echarts/web/echarts.bridge.js @@ -2,146 +2,41 @@ * Created by richie on 16/1/29. */ EChartsFactory = function(options, $dom) { - debugger; - var myChart = echarts.init($dom[0], 'dark'); - var option = { - title : { - text: 'iphone销量', - subtext: '纯属虚构', - x:'center' - }, - tooltip : { - trigger: 'item' - }, - legend: { - orient: 'vertical', - x:'left', - data:['iphone3','iphone4','iphone5'] - }, - dataRange: { - min: 0, - max: 2500, - x: 'left', - y: 'bottom', - text:['高','低'], // 文本,默认为数值文本 - calculable : true - }, - toolbox: { - show: true, - orient : 'vertical', - x: 'right', - y: 'center', - feature : { - mark : {show: true}, - dataView : {show: true, readOnly: false}, - restore : {show: true}, - saveAsImage : {show: true} - } - }, - roamController: { - show: true, - x: 'right', - mapTypeControl: { - 'china': true - } - }, - series : [ - { - name: 'iphone3', - type: 'map', - mapType: 'china', - roam: false, - itemStyle:{ - normal:{label:{show:true}}, - emphasis:{label:{show:true}} - }, - data:[ - {name: '北京',value: Math.round(Math.random()*1000)}, - {name: '天津',value: Math.round(Math.random()*1000)}, - {name: '上海',value: Math.round(Math.random()*1000)}, - {name: '重庆',value: Math.round(Math.random()*1000)}, - {name: '河北',value: Math.round(Math.random()*1000)}, - {name: '河南',value: Math.round(Math.random()*1000)}, - {name: '云南',value: Math.round(Math.random()*1000)}, - {name: '辽宁',value: Math.round(Math.random()*1000)}, - {name: '黑龙江',value: Math.round(Math.random()*1000)}, - {name: '湖南',value: Math.round(Math.random()*1000)}, - {name: '安徽',value: Math.round(Math.random()*1000)}, - {name: '山东',value: Math.round(Math.random()*1000)}, - {name: '新疆',value: Math.round(Math.random()*1000)}, - {name: '江苏',value: Math.round(Math.random()*1000)}, - {name: '浙江',value: Math.round(Math.random()*1000)}, - {name: '江西',value: Math.round(Math.random()*1000)}, - {name: '湖北',value: Math.round(Math.random()*1000)}, - {name: '广西',value: Math.round(Math.random()*1000)}, - {name: '甘肃',value: Math.round(Math.random()*1000)}, - {name: '山西',value: Math.round(Math.random()*1000)}, - {name: '内蒙古',value: Math.round(Math.random()*1000)}, - {name: '陕西',value: Math.round(Math.random()*1000)}, - {name: '吉林',value: Math.round(Math.random()*1000)}, - {name: '福建',value: Math.round(Math.random()*1000)}, - {name: '贵州',value: Math.round(Math.random()*1000)}, - {name: '广东',value: Math.round(Math.random()*1000)}, - {name: '青海',value: Math.round(Math.random()*1000)}, - {name: '西藏',value: Math.round(Math.random()*1000)}, - {name: '四川',value: Math.round(Math.random()*1000)}, - {name: '宁夏',value: Math.round(Math.random()*1000)}, - {name: '海南',value: Math.round(Math.random()*1000)}, - {name: '台湾',value: Math.round(Math.random()*1000)}, - {name: '香港',value: Math.round(Math.random()*1000)}, - {name: '澳门',value: Math.round(Math.random()*1000)} - ] - }, - { - name: 'iphone4', - type: 'map', - mapType: 'china', - itemStyle:{ - normal:{label:{show:true}}, - emphasis:{label:{show:true}} - }, - data:[ - {name: '北京',value: Math.round(Math.random()*1000)}, - {name: '天津',value: Math.round(Math.random()*1000)}, - {name: '上海',value: Math.round(Math.random()*1000)}, - {name: '重庆',value: Math.round(Math.random()*1000)}, - {name: '河北',value: Math.round(Math.random()*1000)}, - {name: '安徽',value: Math.round(Math.random()*1000)}, - {name: '新疆',value: Math.round(Math.random()*1000)}, - {name: '浙江',value: Math.round(Math.random()*1000)}, - {name: '江西',value: Math.round(Math.random()*1000)}, - {name: '山西',value: Math.round(Math.random()*1000)}, - {name: '内蒙古',value: Math.round(Math.random()*1000)}, - {name: '吉林',value: Math.round(Math.random()*1000)}, - {name: '福建',value: Math.round(Math.random()*1000)}, - {name: '广东',value: Math.round(Math.random()*1000)}, - {name: '西藏',value: Math.round(Math.random()*1000)}, - {name: '四川',value: Math.round(Math.random()*1000)}, - {name: '宁夏',value: Math.round(Math.random()*1000)}, - {name: '香港',value: Math.round(Math.random()*1000)}, - {name: '澳门',value: Math.round(Math.random()*1000)} - ] - }, - { - name: 'iphone5', - type: 'map', - mapType: 'china', - itemStyle:{ - normal:{label:{show:true}}, - emphasis:{label:{show:true}} - }, - data:[ - {name: '北京',value: Math.round(Math.random()*1000)}, - {name: '天津',value: Math.round(Math.random()*1000)}, - {name: '上海',value: Math.round(Math.random()*1000)}, - {name: '广东',value: Math.round(Math.random()*1000)}, - {name: '台湾',value: Math.round(Math.random()*1000)}, - {name: '香港',value: Math.round(Math.random()*1000)}, - {name: '澳门',value: Math.round(Math.random()*1000)} - ] - } - ] - }; + this.options = options; + this.$dom = $dom; + this.chartID = options.chartID; + this.autoRefreshTime = options.autoRefreshTime || 0; - myChart.setOption(option); + 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() { + this.newCharts = echarts.init(this.$dom[0]); + this.newCharts.setOption(this.options.chartAttr); + }, + + resize : function() { + + }, + refresh:function(){ + + }, + + refreshData:function(options){ + + }, + + //数据监控的刷新方式 + setData:function(options, aimation){ + + } }; \ No newline at end of file