From d94f23df2917919ef9e93ec9604c9949f559c9d4 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 22 Feb 2016 13:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../echarts/common/EChartsFileLoader.java | 1 + .../chart/echarts/common/base/ECharts.java | 50 ++- .../echarts/common/glyph/EChartsGlyph.java | 28 +- .../common/glyph/EChartsTitleGlyph.java | 4 +- .../echarts/common/theme/EChartsTheme.java | 60 +++ .../common/tooltip/EChartsTooltip.java | 83 +++++ .../echarts/common/tooltip/TriggerType.java | 30 ++ .../echarts/common/ui/EChartsLegendPane.java | 35 ++ .../echarts/common/ui/EChartsStylePane.java | 26 +- .../echarts/common/ui/EChartsThemePane.java | 75 ++++ .../echarts/common/ui/EChartsTitlePane.java | 18 +- .../echarts/common/ui/EChartsTooltipPane.java | 57 ++- .../AbstractEChartsTableDataContentPane.java | 156 +------- .../echarts/common/web/echarts.bridge.js | 341 +----------------- .../echarts/common/web/echarts.loader.js | 5 + .../chart/echarts/common/web/theme/dark.js | 337 +++++++++++++++++ .../chart/echarts/locale/echarts.properties | 11 +- .../echarts/locale/echarts_zh_CN.properties | 11 +- .../pie/glyph/EChartsPiePlotGlyph.java | 57 ++- .../ui/EChartsPieTableDataContentPane.java | 4 +- 20 files changed, 858 insertions(+), 531 deletions(-) create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/theme/EChartsTheme.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/tooltip/EChartsTooltip.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/tooltip/TriggerType.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsLegendPane.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsThemePane.java create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/web/echarts.loader.js create mode 100644 src/com/fr/solution/plugin/chart/echarts/common/web/theme/dark.js diff --git a/src/com/fr/solution/plugin/chart/echarts/common/EChartsFileLoader.java b/src/com/fr/solution/plugin/chart/echarts/common/EChartsFileLoader.java index 1b2c253..eac364c 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/EChartsFileLoader.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/EChartsFileLoader.java @@ -10,6 +10,7 @@ public class EChartsFileLoader extends AbstractJavaScriptFileHandler { @Override public String[] pathsForFiles() { return new String[]{ + "/com/fr/solution/plugin/chart/echarts/common/web/echarts.loader.js", "/com/fr/solution/plugin/chart/echarts/common/web/lib/echarts-all.js" }; } diff --git a/src/com/fr/solution/plugin/chart/echarts/common/base/ECharts.java b/src/com/fr/solution/plugin/chart/echarts/common/base/ECharts.java index 4d642e2..6cbff72 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/base/ECharts.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/base/ECharts.java @@ -16,7 +16,9 @@ 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; @@ -26,16 +28,35 @@ import com.fr.stable.xml.XMLableReader; */ public class ECharts extends Chart { + private EChartsTheme theme; + private EChartsTooltip tooltip; + public ECharts() { - setWrapperName("EChartsFactory"); - setTitle(new EChartsTitle()); + 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 @@ -60,6 +81,13 @@ public class ECharts extends Chart { glyph.setRequiredJS(getRequiredJS()); glyph.setJSDraw(isJSDraw()); + if (theme != null) { + glyph.setTheme(theme); + } + if (tooltip != null) { + glyph.setTooltip(tooltip); + } + return glyph; } @@ -92,6 +120,10 @@ public class ECharts extends Chart { 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); } } } @@ -118,5 +150,19 @@ public class ECharts extends Chart { @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); } } \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsGlyph.java b/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsGlyph.java index c1b2518..e8773c9 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsGlyph.java @@ -4,6 +4,9 @@ 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; /** @@ -11,6 +14,17 @@ import com.fr.stable.web.Repository; */ 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 = new JSONObject(); @@ -18,7 +32,7 @@ public class EChartsGlyph extends ChartGlyph { if (titleGlyph != null) { jo.put("title", titleGlyph.toJSONObject(repo)); } - jo.put("tooltip", createTooltip(repo)); + EChartsLegendGlyph legendGlyph = (EChartsLegendGlyph) getLegendGlyph(); if (legendGlyph != null) { @@ -28,12 +42,12 @@ public class EChartsGlyph extends ChartGlyph { 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; } - - - private JSONObject createTooltip(Repository repo) throws JSONException { - return JSONObject.create() - .put("trigger", "item"); - } } \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsTitleGlyph.java b/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsTitleGlyph.java index 45d55c6..674900e 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsTitleGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/glyph/EChartsTitleGlyph.java @@ -21,8 +21,10 @@ public class EChartsTitleGlyph extends TitleGlyph { } private JSONObject createTitle(Repository repo) throws JSONException { - return JSONObject.create() + JSONObject t = JSONObject.create() .put("text", getText()) .put("x", "center"); + + return t; } } \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/common/theme/EChartsTheme.java b/src/com/fr/solution/plugin/chart/echarts/common/theme/EChartsTheme.java new file mode 100644 index 0000000..8c9f7dc --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/theme/EChartsTheme.java @@ -0,0 +1,60 @@ +package com.fr.solution.plugin.chart.echarts.common.theme; + +import com.fr.general.ComparatorUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; + +/** + * Created by richie on 16/2/22. + */ +public class EChartsTheme implements XMLable { + + public static final String XML_TAG = "Theme"; + + private String name; + + public EChartsTheme() { + this("default"); + } + + public EChartsTheme(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof EChartsTheme + && ComparatorUtils.equals(name, ((EChartsTheme) obj).name); + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isChildNode()) { + String tagName = reader.getTagName(); + if (tagName.equals("ThemeAttr")) { + name = reader.getAttrAsString("name", "default"); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG("ThemeAttr"); + writer.attr("name", name); + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } +} diff --git a/src/com/fr/solution/plugin/chart/echarts/common/tooltip/EChartsTooltip.java b/src/com/fr/solution/plugin/chart/echarts/common/tooltip/EChartsTooltip.java new file mode 100644 index 0000000..cfb6567 --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/tooltip/EChartsTooltip.java @@ -0,0 +1,83 @@ +package com.fr.solution.plugin.chart.echarts.common.tooltip; + +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; + +/** + * Created by richie on 16/2/22. + */ +public class EChartsTooltip implements XMLable { + + public static final String XML_TAG = "Tooltip"; + + private TriggerType triggerType; + private String format; + + public EChartsTooltip() { + + } + + public TriggerType getTriggerType() { + return triggerType; + } + + public void setTriggerType(TriggerType triggerType) { + this.triggerType = triggerType; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public JSONObject toJSONObject(Repository repo) throws JSONException { + JSONObject jo = JSONObject.create(); + jo.put("trigger", triggerType.getType()); + jo.put("formatter", format); + return jo; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof EChartsTooltip + && ComparatorUtils.equals(triggerType, ((EChartsTooltip) obj).triggerType) + && ComparatorUtils.equals(format, ((EChartsTooltip) obj).format); + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isChildNode()) { + String tagName = reader.getTagName(); + if (tagName.equals("Attr")) { + triggerType = TriggerType.parse(reader.getAttrAsString("trigger", "")); + format = reader.getAttrAsString("format", ""); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG("Attr"); + if (triggerType != null) { + writer.attr("trigger", triggerType.getType()); + } + if (StringUtils.isNotEmpty(format)) { + writer.attr("format", format); + } + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } +} diff --git a/src/com/fr/solution/plugin/chart/echarts/common/tooltip/TriggerType.java b/src/com/fr/solution/plugin/chart/echarts/common/tooltip/TriggerType.java new file mode 100644 index 0000000..439b49f --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/tooltip/TriggerType.java @@ -0,0 +1,30 @@ +package com.fr.solution.plugin.chart.echarts.common.tooltip; + +import com.fr.general.ComparatorUtils; + +/** + * Created by richie on 16/2/22. + */ +public enum TriggerType { + + ITEM("item"), AXIS("axis"); + + private String type; + + TriggerType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + + public static TriggerType parse(String type) { + for (TriggerType tt : values()) { + if (ComparatorUtils.equals(type, tt.type)) { + return tt; + } + } + return ITEM; + } +} diff --git a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsLegendPane.java b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsLegendPane.java new file mode 100644 index 0000000..f068300 --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsLegendPane.java @@ -0,0 +1,35 @@ +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 javax.swing.*; +import java.awt.*; + +/** + * Created by richie on 16/2/22. + */ +public class EChartsLegendPane extends BasicScrollPane { + + public EChartsLegendPane(EChartsStylePane parent) { + + } + @Override + protected JPanel createContentPane() { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(new UILabel("待开发", SwingConstants.CENTER), BorderLayout.CENTER); + return panel; + } + + @Override + public void populateBean(ECharts ob) { + + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Plugin-ECharts_Legend"); + } +} diff --git a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsStylePane.java b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsStylePane.java index a30d7a8..43a9986 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsStylePane.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsStylePane.java @@ -9,6 +9,7 @@ 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 javax.swing.*; @@ -23,6 +24,8 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve private EChartsTitlePane titlePane; private BasicPane tooltipPane; + private BasicPane themePane; + private BasicPane legendPane; private AttributeChangeListener listener; private UIObserverListener uiObserverListener; @@ -39,7 +42,19 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve tooltipPane = new BasicPane() { @Override protected String title4PopupWindow() { - return "Tooltip"; + return Inter.getLocText("Plugin-ECharts_Tooltip"); + } + }; + themePane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Plugin-ECharts_Theme"); + } + }; + legendPane = new BasicPane() { + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Plugin-ECharts_Legend"); } }; } @@ -156,6 +171,10 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve */ if (chosenPane == tooltipPane) { chosenPane = new EChartsTooltipPane(EChartsStylePane.this); + } else if (chosenPane == themePane) { + chosenPane = new EChartsThemePane(EChartsStylePane.this); + } else if (chosenPane == legendPane) { + chosenPane = new EChartsLegendPane(EChartsStylePane.this); } initSelfListener(chosenPane); @@ -175,6 +194,8 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve java.util.List paneList = new ArrayList(); paneList.add(titlePane); paneList.add(tooltipPane); + paneList.add(themePane); + paneList.add(legendPane); return paneList; } @@ -197,7 +218,8 @@ public class EChartsStylePane extends AbstractChartAttrPane implements UIObserve @Override public void updateBean(ECharts ob) { - ((BasicBeanPane) paneList.get(kindOfTabPane.getSelectedIndex())).updateBean(ob); + BasicBeanPane pane = ((BasicBeanPane) paneList.get(kindOfTabPane.getSelectedIndex())); + pane.updateBean(ob); } @Override diff --git a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsThemePane.java b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsThemePane.java new file mode 100644 index 0000000..b640e1d --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsThemePane.java @@ -0,0 +1,75 @@ +package com.fr.solution.plugin.chart.echarts.common.ui; + +import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.icombobox.UIDictionaryComboBox; +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.theme.EChartsTheme; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by richie on 16/2/22. + */ +public class EChartsThemePane extends BasicScrollPane { + + private static final String[] themes = new String[]{"default", "dark"}; + + private UIDictionaryComboBox themeComboBox; + + + public EChartsThemePane(EChartsStylePane stylePane) { + + } + + @Override + protected JPanel createContentPane() { + JPanel panel = new JPanel(new BorderLayout()); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p}; + double[] columnSize = {p, f}; + + UILabel titleLabel = new UILabel(Inter.getLocText("Plugin-ECharts_Theme_Select")); + + themeComboBox = new UIDictionaryComboBox( + new String[]{"default", "dark"}, + new String[]{"默认", "暗黑"}); + + JPanel cen = TableLayoutHelper.createTableLayoutPane(new Component[][] { + {titleLabel, themeComboBox} + },rowSize, columnSize); + panel.add(cen, BorderLayout.CENTER); + return panel; + } + + @Override + public void populateBean(ECharts ob) { + if (ob == null) { + return; + } + EChartsTheme theme = ob.getTheme(); + if (theme != null) { + themeComboBox.setSelectedItem(theme.getName()); + } + } + + @Override + public void updateBean(ECharts ob) { + if (ob == null) { + ob = new ECharts(); + } + EChartsTheme theme = new EChartsTheme(); + theme.setName(themeComboBox.getSelectedItem()); + ob.setTheme(theme); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("Plugin-ECharts_Theme"); + } +} diff --git a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTitlePane.java b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTitlePane.java index 04a563b..dbd1430 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTitlePane.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTitlePane.java @@ -1,7 +1,6 @@ package com.fr.solution.plugin.chart.echarts.common.ui; import com.fr.base.Formula; -import com.fr.base.Utils; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -9,6 +8,7 @@ import com.fr.design.gui.ilable.UILabel; 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.title.EChartsTitle; import com.fr.stable.StableUtils; @@ -38,12 +38,16 @@ public class EChartsTitlePane extends BasicScrollPane { double f = TableLayout.FILL; double[] rowSize = {p, p}; double[] columnSize = {p, f}; - showTitle = new UIButtonGroup(new String[]{"显示", "不显示"}, new Boolean[]{true, false}); + showTitle = new UIButtonGroup( + new String[]{ + Inter.getLocText("Plugin-ECharts_Title_Show"), + Inter.getLocText("Plugin-ECharts_Title_Not_Show")}, + new Boolean[]{true, false}); showTitle.setSelectedIndex(0); tinyFormulaPane = new TinyFormulaPane(); JPanel cen = TableLayoutHelper.createTableLayoutPane(new Component[][]{ - {new UILabel("显示标题"), showTitle}, - {new UILabel("标题内容"), tinyFormulaPane} + {new UILabel(Inter.getLocText("Plugin-ECharts_Title_Show_Label")), showTitle}, + {new UILabel(Inter.getLocText("Plugin-ECharts_Title_Content")), tinyFormulaPane} }, rowSize, columnSize); panel.add(cen, BorderLayout.CENTER); return panel; @@ -55,7 +59,7 @@ public class EChartsTitlePane extends BasicScrollPane { if (title == null) { return; } - showTitle.setSelectedItem(title.isTitleVisble()); + showTitle.setSelectedItem(title.isTitleVisible()); if (title.getTextObject() instanceof Formula) { tinyFormulaPane.populateBean(((Formula) title.getTextObject()).getContent()); } else { @@ -72,7 +76,7 @@ public class EChartsTitlePane extends BasicScrollPane { if (title == null) { title = new EChartsTitle(); } - title.setTitleVisble(showTitle.getSelectedItem()); + title.setTitleVisible(showTitle.getSelectedItem()); String titleString = tinyFormulaPane.updateBean(); Object titleObj; if (StableUtils.maybeFormula(titleString)) { @@ -85,6 +89,6 @@ public class EChartsTitlePane extends BasicScrollPane { @Override protected String title4PopupWindow() { - return "Title"; + return Inter.getLocText("Plugin-ECharts_Title"); } } diff --git a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTooltipPane.java b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTooltipPane.java index a5b82fe..efc9509 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTooltipPane.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/ui/EChartsTooltipPane.java @@ -1,31 +1,84 @@ package com.fr.solution.plugin.chart.echarts.common.ui; import com.fr.design.dialog.BasicScrollPane; +import com.fr.design.gui.icombobox.UIDictionaryComboBox; +import com.fr.design.gui.ilable.UILabel; +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.tooltip.EChartsTooltip; +import com.fr.solution.plugin.chart.echarts.common.tooltip.TriggerType; import javax.swing.*; +import java.awt.*; /** * Created by richie on 16/2/19. */ public class EChartsTooltipPane extends BasicScrollPane { + private UIDictionaryComboBox triggerComboBox; + private UITextField formatterTextField; + public EChartsTooltipPane(EChartsStylePane parent) { } @Override protected JPanel createContentPane() { - return new JPanel(); + JPanel panel = new JPanel(); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] rowSize = {p, p}; + double[] columnSize = {p, f}; + + UILabel titleLabel = new UILabel("触发点"); + + triggerComboBox = new UIDictionaryComboBox( + new TriggerType[]{TriggerType.ITEM, TriggerType.AXIS}, + new String[]{"图例", "坐标轴"}); + + UILabel formatterLabel = new UILabel("显示格式"); + + formatterTextField = new UITextField(12); + + JPanel cen = TableLayoutHelper.createTableLayoutPane(new Component[][] { + {titleLabel, triggerComboBox}, + {formatterLabel, formatterTextField} + },rowSize, columnSize); + panel.add(cen, BorderLayout.CENTER); + + return panel; } @Override public void populateBean(ECharts ob) { + if (ob == null) { + return; + } + EChartsTooltip tooltip = ob.getTooltip(); + if (tooltip == null) { + return; + } + triggerComboBox.setSelectedItem(tooltip.getTriggerType()); + formatterTextField.setText(tooltip.getFormat()); + } + @Override + public void updateBean(ECharts ob) { + if (ob == null) { + ob = new ECharts(); + } + EChartsTooltip tooltip = new EChartsTooltip(); + tooltip.setTriggerType(triggerComboBox.getSelectedItem()); + tooltip.setFormat(formatterTextField.getText()); + ob.setTooltip(tooltip); } @Override protected String title4PopupWindow() { - return "Tooltip"; + return Inter.getLocText("Plugin-ECharts_Tooltip"); } } diff --git a/src/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsTableDataContentPane.java b/src/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsTableDataContentPane.java index 1b30ff9..848ef2f 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsTableDataContentPane.java +++ b/src/com/fr/solution/plugin/chart/echarts/common/ui/data/AbstractEChartsTableDataContentPane.java @@ -1,164 +1,14 @@ package com.fr.solution.plugin.chart.echarts.common.ui.data; -import com.fr.chart.base.ChartConstants; -import com.fr.chart.chartattr.Bar2DPlot; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartdata.NormalTableDataDefinition; -import com.fr.chart.chartdata.TopDefinition; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.BoldFontTextLabel; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.ComparatorUtils; -import com.fr.general.Inter; -import com.fr.solution.plugin.chart.echarts.common.ui.series.NewSeriesTypeUsePane; -import com.fr.stable.ArrayUtils; -import com.fr.stable.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; /** * Created by richie on 16/1/29. */ -public class AbstractEChartsTableDataContentPane extends AbstractTableDataContentPane { - - protected UIComboBox categoryComboBox; - protected NewSeriesTypeUsePane seriesTypeUsePane; - +public class AbstractEChartsTableDataContentPane extends CategoryPlotTableDataContentPane { public AbstractEChartsTableDataContentPane(ChartDataPane parent) { - - categoryComboBox = new UIComboBox(); - JPanel categoryPane = new JPanel(new BorderLayout(4, 0)); - categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel label1 = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Category_Name") + ":", SwingConstants.RIGHT); - label1.setPreferredSize(new Dimension(75, 20)); - categoryComboBox.setPreferredSize(new Dimension(100, 20)); - - categoryComboBox.addItem(Inter.getLocText("Chart-Use_None")); - categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryComboBox, null, null, label1, null})); - - this.setLayout(new BorderLayout()); - - this.add(categoryPane, BorderLayout.NORTH); - - seriesTypeUsePane = new NewSeriesTypeUsePane(parent, new Bar2DPlot()); - this.add(seriesTypeUsePane, BorderLayout.SOUTH); - - categoryComboBox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - checkSeriseUse(categoryComboBox.getSelectedItem() != null); - makeToolTipUse(categoryComboBox); - } - }); - } - - protected void makeToolTipUse(UIComboBox comBox) { - if (comBox.getSelectedItem() != null) { - comBox.setToolTipText(comBox.getSelectedItem().toString()); - } else { - comBox.setToolTipText(null); - } - } - - /** - * 检查 某些Box是否可用 - * - * @param hasUse 是否使用. - */ - public void checkBoxUse(boolean hasUse) { - categoryComboBox.setEnabled(hasUse); - checkSeriseUse(hasUse); - } - - protected void checkSeriseUse(boolean hasUse) { - if (seriesTypeUsePane != null) { - seriesTypeUsePane.checkUseBox(hasUse && categoryComboBox.getSelectedItem() != null); - } - } - - protected void refreshBoxListWithSelectTableData(java.util.List list) { - refreshBoxItems(categoryComboBox, list); - categoryComboBox.addItem(Inter.getLocText("Chart-Use_None")); - - seriesTypeUsePane.refreshBoxListWithSelectTableData(list); + super(parent); } - - /** - * 清空所有的box设置 - */ - public void clearAllBoxList() { - clearBoxItems(categoryComboBox); - categoryComboBox.addItem(Inter.getLocText("Chart-Use_None")); - seriesTypeUsePane.clearAllBoxList(); - } - - /** - * 保存界面内容到ChartCollection - */ - public void updateBean(ChartCollection collection) { - seriesTypeUsePane.updateBean(collection); - NormalTableDataDefinition dataDefinition = (NormalTableDataDefinition) collection.getSelectedChart().getFilterDefinition(); - if (dataDefinition == null) { - return; - } - Object categoryName = categoryComboBox.getSelectedItem(); - - if (ArrayUtils.contains(ChartConstants.NONE_KEYS, categoryName)) { - dataDefinition.setCategoryName(StringUtils.EMPTY); - } else { - dataDefinition.setCategoryName(categoryName == null ? null : categoryName.toString()); - } - - } - - /** - * 根据ChartCollection 更新界面 - */ - public void populateBean(ChartCollection collection) { - super.populateBean(collection); - TopDefinition top = (TopDefinition) collection.getSelectedChart().getFilterDefinition(); - - if (!(top instanceof NormalTableDataDefinition)) { - return; - } - NormalTableDataDefinition data = (NormalTableDataDefinition) top; - - if (data == null || ComparatorUtils.equals(data.getCategoryName(), StringUtils.EMPTY)) { - categoryComboBox.setSelectedItem(Inter.getLocText("Chart-Use_None")); - } else if (data != null && !this.boxItemsContainsObject(categoryComboBox, data.getCategoryName())) { - categoryComboBox.setSelectedItem(null); - } else { - combineCustomEditValue(categoryComboBox, data == null ? null : data.getCategoryName()); - } - - seriesTypeUsePane.populateBean(collection, this.isNeedSummaryCaculateMethod()); - } - - private boolean boxItemsContainsObject(UIComboBox box, Object item) { - if (box == null) { - return false; - } - - ComboBoxModel dataModel = box.getModel(); - for (int i = 0; i < dataModel.getSize(); i++) { - if (ComparatorUtils.equals(dataModel.getElementAt(i), item)) { - return true; - } - } - return false; - } - - /** - * 重新布局整个面板 - */ - public void redoLayoutPane() { - seriesTypeUsePane.relayoutPane(this.isNeedSummaryCaculateMethod()); - } - } \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.bridge.js b/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.bridge.js index 642b195..ccc2387 100644 --- a/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.bridge.js +++ b/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.bridge.js @@ -20,340 +20,13 @@ EChartsFactory.prototype = { constructor : EChartsFactory, inits : function() { - var theme = { - // 全图默认背景 - backgroundColor: '#1b1b1b', - - // 默认色板 - color: [ - '#FE8463','#9BCA63','#FAD860','#60C0DD','#0084C6', - '#D7504B','#C6E579','#26C0C0','#F0805A','#F4E001', - '#B5C334' - ], - - // 图表标题 - title: { - textStyle: { - fontWeight: 'normal', - color: '#fff' // 主标题文字颜色 - } - }, - - // 图例 - legend: { - textStyle: { - color: '#ccc' // 图例文字颜色 - } - }, - - // 值域 - dataRange: { - itemWidth: 15, - color: ['#FFF808','#21BCF9'], - textStyle: { - color: '#ccc' // 值域文字颜色 - } - }, - - toolbox: { - color : ['#fff', '#fff', '#fff', '#fff'], - effectiveColor : '#FE8463', - disableColor: '#666' - }, - - // 提示框 - tooltip: { - backgroundColor: 'rgba(250,250,250,0.8)', // 提示背景颜色,默认为透明度为0.7的黑色 - axisPointer : { // 坐标轴指示器,坐标轴触发有效 - type : 'line', // 默认为直线,可选为:'line' | 'shadow' - lineStyle : { // 直线指示器样式设置 - color: '#aaa' - }, - crossStyle: { - color: '#aaa' - }, - shadowStyle : { // 阴影指示器样式设置 - color: 'rgba(200,200,200,0.2)' - } - }, - textStyle: { - color: '#333' - } - }, - - // 区域缩放控制器 - dataZoom: { - dataBackgroundColor: '#555', // 数据背景颜色 - fillerColor: 'rgba(200,200,200,0.2)', // 填充颜色 - handleColor: '#eee' // 手柄颜色 - }, - - // 网格 - grid: { - borderWidth: 0 - }, - - // 类目轴 - categoryAxis: { - axisLine: { // 坐标轴线 - show: false - }, - axisTick: { // 坐标轴小标记 - show: false - }, - axisLabel: { // 坐标轴文本标签,详见axis.axisLabel - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - color: '#ccc' - } - }, - splitLine: { // 分隔线 - show: false - } - }, - - // 数值型坐标轴默认参数 - valueAxis: { - axisLine: { // 坐标轴线 - show: false - }, - axisTick: { // 坐标轴小标记 - show: false - }, - axisLabel: { // 坐标轴文本标签,详见axis.axisLabel - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - color: '#ccc' - } - }, - splitLine: { // 分隔线 - lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式 - color: ['#aaa'], - type: 'dashed' - } - }, - splitArea: { // 分隔区域 - show: false - } - }, - - polar : { - name : { - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - color: '#ccc' - } - }, - axisLine: { // 坐标轴线 - lineStyle: { // 属性lineStyle控制线条样式 - color: '#ddd' - } - }, - splitArea : { - show : true, - areaStyle : { - color: ['rgba(250,250,250,0.2)','rgba(200,200,200,0.2)'] - } - }, - splitLine : { - lineStyle : { - color : '#ddd' - } - } - }, - - timeline : { - label: { - textStyle:{ - color: '#ccc' - } - }, - lineStyle : { - color : '#aaa' - }, - controlStyle : { - normal : { color : '#fff'}, - emphasis : { color : '#FE8463'} - }, - symbolSize : 3 - }, - - // 折线图默认参数 - line: { - smooth : true - }, - - // K线图默认参数 - k: { - itemStyle: { - normal: { - color: '#FE8463', // 阳线填充颜色 - color0: '#9BCA63', // 阴线填充颜色 - lineStyle: { - width: 1, - color: '#FE8463', // 阳线边框颜色 - color0: '#9BCA63' // 阴线边框颜色 - } - } - } - }, - - // 雷达图默认参数 - radar : { - symbol: 'emptyCircle', // 图形类型 - symbolSize:3 - //symbol: null, // 拐点图形类型 - //symbolRotate : null, // 图形旋转控制 - }, - - pie: { - itemStyle: { - normal: { - borderWidth: 1, - borderColor : 'rgba(255, 255, 255, 0.5)' - }, - emphasis: { - borderWidth: 1, - borderColor : 'rgba(255, 255, 255, 1)' - } - } - }, - - map: { - itemStyle: { - normal: { - borderColor:'rgba(255, 255, 255, 0.5)', - areaStyle: { - color: '#ddd' - }, - label: { - textStyle: { - // color: '#ccc' - } - } - }, - emphasis: { // 也是选中样式 - areaStyle: { - color: '#FE8463' - }, - label: { - textStyle: { - // color: 'ccc' - } - } - } - } - }, - - force : { - itemStyle: { - normal: { - linkStyle : { - color : '#fff' - } - } - } - }, - - chord : { - itemStyle : { - normal : { - borderWidth: 1, - borderColor: 'rgba(228, 228, 228, 0.2)', - chordStyle : { - lineStyle : { - color : 'rgba(228, 228, 228, 0.2)' - } - } - }, - emphasis : { - borderWidth: 1, - borderColor: 'rgba(228, 228, 228, 0.9)', - chordStyle : { - lineStyle : { - color : 'rgba(228, 228, 228, 0.9)' - } - } - } - } - }, - - gauge : { - axisLine: { // 坐标轴线 - show: true, // 默认显示,属性show控制显示与否 - lineStyle: { // 属性lineStyle控制线条样式 - color: [[0.2, '#9BCA63'],[0.8, '#60C0DD'],[1, '#D7504B']], - width: 3, - shadowColor : '#fff', //默认透明 - shadowBlur: 10 - } - }, - axisTick: { // 坐标轴小标记 - length :15, // 属性length控制线长 - lineStyle: { // 属性lineStyle控制线条样式 - color: 'auto', - shadowColor : '#fff', //默认透明 - shadowBlur: 10 - } - }, - axisLabel: { // 坐标轴小标记 - textStyle: { // 属性lineStyle控制线条样式 - fontWeight: 'bolder', - color: '#fff', - shadowColor : '#fff', //默认透明 - shadowBlur: 10 - } - }, - splitLine: { // 分隔线 - length :25, // 属性length控制线长 - lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式 - width:3, - color: '#fff', - shadowColor : '#fff', //默认透明 - shadowBlur: 10 - } - }, - pointer: { // 分隔线 - shadowColor : '#fff', //默认透明 - shadowBlur: 5 - }, - title : { - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - fontWeight: 'bolder', - fontSize: 20, - fontStyle: 'italic', - color: '#fff', - shadowColor : '#fff', //默认透明 - shadowBlur: 10 - } - }, - detail : { - shadowColor : '#fff', //默认透明 - shadowBlur: 5, - offsetCenter: [0, '50%'], // x, y,单位px - textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE - fontWeight: 'bolder', - color: '#fff' - } - } - }, - - funnel : { - itemStyle: { - normal: { - borderColor : 'rgba(255, 255, 255, 0.5)', - borderWidth: 1 - }, - emphasis: { - borderColor : 'rgba(255, 255, 255, 1)', - borderWidth: 1 - } - } - }, - - textStyle: { - fontFamily: '微软雅黑, Arial, Verdana, sans-serif' - } - }; - this.newCharts = echarts.init(this.$dom[0], theme); - this.newCharts.setOption(this.options.chartAttr); + debugger; + var ct = this.options.chartAttr; + if (ct.theme != 'default') { + FR.$defaultImport('/com/fr/solution/plugin/chart/echarts/common/web/theme/' + ct.theme + '.js'); + } + this.newCharts = echarts.init(this.$dom[0], EChartsTheme[ct.theme]); + this.newCharts.setOption(ct); }, resize : function() { diff --git a/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.loader.js b/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.loader.js new file mode 100644 index 0000000..35d702f --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/web/echarts.loader.js @@ -0,0 +1,5 @@ +(function(){ + if (!window.EChartsTheme) { + window.EChartsTheme = {}; + } +})(); \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/common/web/theme/dark.js b/src/com/fr/solution/plugin/chart/echarts/common/web/theme/dark.js new file mode 100644 index 0000000..46cbc42 --- /dev/null +++ b/src/com/fr/solution/plugin/chart/echarts/common/web/theme/dark.js @@ -0,0 +1,337 @@ +(function(){ + $.extend(window.EChartsTheme, { + + dark : { + // 全图默认背景 + backgroundColor: '#1b1b1b', + + // 默认色板 + color: [ + '#FE8463', '#9BCA63', '#FAD860', '#60C0DD', '#0084C6', + '#D7504B', '#C6E579', '#26C0C0', '#F0805A', '#F4E001', + '#B5C334' + ], + + // 图表标题 + title: { + textStyle: { + fontWeight: 'normal', + color: '#fff' // 主标题文字颜色 + } + }, + + // 图例 + legend: { + textStyle: { + color: '#ccc' // 图例文字颜色 + } + }, + + // 值域 + dataRange: { + itemWidth: 15, + color: ['#FFF808', '#21BCF9'], + textStyle: { + color: '#ccc' // 值域文字颜色 + } + }, + + toolbox: { + color: ['#fff', '#fff', '#fff', '#fff'], + effectiveColor: '#FE8463', + disableColor: '#666' + }, + + // 提示框 + tooltip: { + backgroundColor: 'rgba(250,250,250,0.8)', // 提示背景颜色,默认为透明度为0.7的黑色 + axisPointer: { // 坐标轴指示器,坐标轴触发有效 + type: 'line', // 默认为直线,可选为:'line' | 'shadow' + lineStyle: { // 直线指示器样式设置 + color: '#aaa' + }, + crossStyle: { + color: '#aaa' + }, + shadowStyle: { // 阴影指示器样式设置 + color: 'rgba(200,200,200,0.2)' + } + }, + textStyle: { + color: '#333' + } + }, + + // 区域缩放控制器 + dataZoom: { + dataBackgroundColor: '#555', // 数据背景颜色 + fillerColor: 'rgba(200,200,200,0.2)', // 填充颜色 + handleColor: '#eee' // 手柄颜色 + }, + + // 网格 + grid: { + borderWidth: 0 + }, + + // 类目轴 + categoryAxis: { + axisLine: { // 坐标轴线 + show: false + }, + axisTick: { // 坐标轴小标记 + show: false + }, + axisLabel: { // 坐标轴文本标签,详见axis.axisLabel + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + color: '#ccc' + } + }, + splitLine: { // 分隔线 + show: false + } + }, + + // 数值型坐标轴默认参数 + valueAxis: { + axisLine: { // 坐标轴线 + show: false + }, + axisTick: { // 坐标轴小标记 + show: false + }, + axisLabel: { // 坐标轴文本标签,详见axis.axisLabel + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + color: '#ccc' + } + }, + splitLine: { // 分隔线 + lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式 + color: ['#aaa'], + type: 'dashed' + } + }, + splitArea: { // 分隔区域 + show: false + } + }, + + polar: { + name: { + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + color: '#ccc' + } + }, + axisLine: { // 坐标轴线 + lineStyle: { // 属性lineStyle控制线条样式 + color: '#ddd' + } + }, + splitArea: { + show: true, + areaStyle: { + color: ['rgba(250,250,250,0.2)', 'rgba(200,200,200,0.2)'] + } + }, + splitLine: { + lineStyle: { + color: '#ddd' + } + } + }, + + timeline: { + label: { + textStyle: { + color: '#ccc' + } + }, + lineStyle: { + color: '#aaa' + }, + controlStyle: { + normal: {color: '#fff'}, + emphasis: {color: '#FE8463'} + }, + symbolSize: 3 + }, + + // 折线图默认参数 + line: { + smooth: true + }, + + // K线图默认参数 + k: { + itemStyle: { + normal: { + color: '#FE8463', // 阳线填充颜色 + color0: '#9BCA63', // 阴线填充颜色 + lineStyle: { + width: 1, + color: '#FE8463', // 阳线边框颜色 + color0: '#9BCA63' // 阴线边框颜色 + } + } + } + }, + + // 雷达图默认参数 + radar: { + symbol: 'emptyCircle', // 图形类型 + symbolSize: 3 + //symbol: null, // 拐点图形类型 + //symbolRotate : null, // 图形旋转控制 + }, + + pie: { + itemStyle: { + normal: { + borderWidth: 1, + borderColor: 'rgba(255, 255, 255, 0.5)' + }, + emphasis: { + borderWidth: 1, + borderColor: 'rgba(255, 255, 255, 1)' + } + } + }, + + map: { + itemStyle: { + normal: { + borderColor: 'rgba(255, 255, 255, 0.5)', + areaStyle: { + color: '#ddd' + }, + label: { + textStyle: { + // color: '#ccc' + } + } + }, + emphasis: { // 也是选中样式 + areaStyle: { + color: '#FE8463' + }, + label: { + textStyle: { + // color: 'ccc' + } + } + } + } + }, + + force: { + itemStyle: { + normal: { + linkStyle: { + color: '#fff' + } + } + } + }, + + chord: { + itemStyle: { + normal: { + borderWidth: 1, + borderColor: 'rgba(228, 228, 228, 0.2)', + chordStyle: { + lineStyle: { + color: 'rgba(228, 228, 228, 0.2)' + } + } + }, + emphasis: { + borderWidth: 1, + borderColor: 'rgba(228, 228, 228, 0.9)', + chordStyle: { + lineStyle: { + color: 'rgba(228, 228, 228, 0.9)' + } + } + } + } + }, + + gauge: { + axisLine: { // 坐标轴线 + show: true, // 默认显示,属性show控制显示与否 + lineStyle: { // 属性lineStyle控制线条样式 + color: [[0.2, '#9BCA63'], [0.8, '#60C0DD'], [1, '#D7504B']], + width: 3, + shadowColor: '#fff', //默认透明 + shadowBlur: 10 + } + }, + axisTick: { // 坐标轴小标记 + length: 15, // 属性length控制线长 + lineStyle: { // 属性lineStyle控制线条样式 + color: 'auto', + shadowColor: '#fff', //默认透明 + shadowBlur: 10 + } + }, + axisLabel: { // 坐标轴小标记 + textStyle: { // 属性lineStyle控制线条样式 + fontWeight: 'bolder', + color: '#fff', + shadowColor: '#fff', //默认透明 + shadowBlur: 10 + } + }, + splitLine: { // 分隔线 + length: 25, // 属性length控制线长 + lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式 + width: 3, + color: '#fff', + shadowColor: '#fff', //默认透明 + shadowBlur: 10 + } + }, + pointer: { // 分隔线 + shadowColor: '#fff', //默认透明 + shadowBlur: 5 + }, + title: { + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + fontWeight: 'bolder', + fontSize: 20, + fontStyle: 'italic', + color: '#fff', + shadowColor: '#fff', //默认透明 + shadowBlur: 10 + } + }, + detail: { + shadowColor: '#fff', //默认透明 + shadowBlur: 5, + offsetCenter: [0, '50%'], // x, y,单位px + textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE + fontWeight: 'bolder', + color: '#fff' + } + } + }, + + funnel: { + itemStyle: { + normal: { + borderColor: 'rgba(255, 255, 255, 0.5)', + borderWidth: 1 + }, + emphasis: { + borderColor: 'rgba(255, 255, 255, 1)', + borderWidth: 1 + } + } + }, + + textStyle: { + fontFamily: '微软雅黑, Arial, Verdana, sans-serif' + } + } + }); +})(); \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/locale/echarts.properties b/src/com/fr/solution/plugin/chart/echarts/locale/echarts.properties index 5128e77..ca35897 100644 --- a/src/com/fr/solution/plugin/chart/echarts/locale/echarts.properties +++ b/src/com/fr/solution/plugin/chart/echarts/locale/echarts.properties @@ -1,2 +1,11 @@ Plugin-ECharts_Chinese_Map=Chinese Map -Plugin-ECharts_Pie=Pie(ECharts) \ No newline at end of file +Plugin-ECharts_Pie=Pie(ECharts) +Plugin-ECharts_Title=Title +Plugin-ECharts_Title_Show=Show Title +Plugin-ECharts_Title_Not_Show=Hide Title +Plugin-ECharts_Title_Show_Label=Show Title +Plugin-ECharts_Title_Content=Content +Plugin-ECharts_Tooltip=Theme +Plugin-ECharts_Theme=Theme +Plugin-ECharts_Theme_Select=Select Theme +Plugin-ECharts_Legend=Legend diff --git a/src/com/fr/solution/plugin/chart/echarts/locale/echarts_zh_CN.properties b/src/com/fr/solution/plugin/chart/echarts/locale/echarts_zh_CN.properties index ab2b670..1e20f71 100644 --- a/src/com/fr/solution/plugin/chart/echarts/locale/echarts_zh_CN.properties +++ b/src/com/fr/solution/plugin/chart/echarts/locale/echarts_zh_CN.properties @@ -1,2 +1,11 @@ Plugin-ECharts_Chinese_Map=\u4E2D\u56FD\u5730\u56FE -Plugin-ECharts_Pie=\u997C\u56FE(ECharts) \ No newline at end of file +Plugin-ECharts_Pie=\u997C\u56FE(ECharts) +Plugin-ECharts_Title=\u6807\u9898 +Plugin-ECharts_Title_Show=\u663E\u793A +Plugin-ECharts_Title_Not_Show=\u4E0D\u663E\u793A +Plugin-ECharts_Title_Show_Label=\u663E\u793A\u6807\u9898 +Plugin-ECharts_Title_Content=\u6807\u9898\u5185\u5BB9 +Plugin-ECharts_Tooltip=\u6807\u7B7E +Plugin-ECharts_Theme=\u4E3B\u9898 +Plugin-ECharts_Theme_Select=\u4E3B\u9898\u9009\u62E9 +Plugin-ECharts_Legend=\u56FE\u4F8B \ No newline at end of file diff --git a/src/com/fr/solution/plugin/chart/echarts/pie/glyph/EChartsPiePlotGlyph.java b/src/com/fr/solution/plugin/chart/echarts/pie/glyph/EChartsPiePlotGlyph.java index 06bc983..f7b3530 100644 --- a/src/com/fr/solution/plugin/chart/echarts/pie/glyph/EChartsPiePlotGlyph.java +++ b/src/com/fr/solution/plugin/chart/echarts/pie/glyph/EChartsPiePlotGlyph.java @@ -10,11 +10,16 @@ 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. */ public class EChartsPiePlotGlyph extends EChartsPlotGlyph { + private static final NumberFormat format = new DecimalFormat("##%"); + private RoseType roseType; public EChartsPiePlotGlyph() { @@ -37,27 +42,41 @@ public class EChartsPiePlotGlyph extends EChartsPlotGlyph { public JSONArray toSeriesData(Repository repo) throws JSONException { JSONArray result = JSONArray.create(); - JSONObject wrapper = JSONObject.create(); - result.put(wrapper); - wrapper.put("type", "pie"); - 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(0); - item.put("value", dataPoint.getValue()); + 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; } } diff --git a/src/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieTableDataContentPane.java b/src/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieTableDataContentPane.java index 2acfe33..541201f 100644 --- a/src/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieTableDataContentPane.java +++ b/src/com/fr/solution/plugin/chart/echarts/pie/ui/EChartsPieTableDataContentPane.java @@ -1,12 +1,12 @@ package com.fr.solution.plugin.chart.echarts.pie.ui; import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.mainframe.chart.gui.data.table.PiePlotTableDataContentPane; +import com.fr.solution.plugin.chart.echarts.common.ui.data.AbstractEChartsTableDataContentPane; /** * Created by richie on 16/2/18. */ -public class EChartsPieTableDataContentPane extends PiePlotTableDataContentPane { +public class EChartsPieTableDataContentPane extends AbstractEChartsTableDataContentPane { public EChartsPieTableDataContentPane(ChartDataPane parent) { super(parent);