From 25f188add6dece51f0e3652924b342ff550b13f3 Mon Sep 17 00:00:00 2001 From: datagear Date: Thu, 23 Jan 2020 21:18:04 +0800 Subject: [PATCH] =?UTF-8?q?[analysis]=E5=B0=86HTML=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=AE=9A=E4=B9=89=E6=96=87=E4=BB=B6=E8=A7=84?= =?UTF-8?q?=E8=8C=83properties.json=E3=80=81chart.js=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E4=B8=BA=E5=8D=95=E4=B8=AAplugin.js=E6=96=87=E4=BB=B6=E8=A7=84?= =?UTF-8?q?=E8=8C=83=EF=BC=8C=E4=BB=A5=E7=AE=80=E5=8C=96=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/datagear/analysis/ChartPlugin.java | 10 + .../org/datagear/analysis/ChartProperty.java | 7 + .../java/org/datagear/analysis/Dashboard.java | 5 + .../org/datagear/analysis/DashboardTheme.java | 2 + .../java/org/datagear/analysis/DataSign.java | 6 + .../org/datagear/analysis/RenderContext.java | 2 + .../JsonChartPluginPropertiesResolver.java | 106 ++-- .../analysis/support/LocationIcon.java | 2 + .../html/DirectoryHtmlChartPluginManager.java | 2 +- .../support/html/HtmlChartPlugin.java | 21 +- .../html/HtmlChartPluginJsDefResolver.java | 268 ++++++++++ .../support/html/HtmlChartPluginLoader.java | 82 ++-- .../HtmlChartPluginScriptObjectWriter.java | 14 +- .../HtmlTplDashboardWidgetFmkRenderer.java | 46 +- .../HtmlTplDashboardWidgetHtmlRenderer.java | 2 +- .../html/HtmlTplDashboardWidgetRenderer.java | 50 +- .../support/html/TextParserSupport.java | 458 ++++++++++++++++++ .../support/html/ValueHtmlChartPlugin.java | 79 ++- ...JsonChartPluginPropertiesResolverTest.java | 16 +- .../HtmlChartPluginJsDefResolverTest.java | 153 ++++++ .../support/html/HtmlChartPluginTest.java | 20 +- .../support/html/HtmlChartPlugin.chart.js | 24 - .../support/html/HtmlChartPlugin.config.json | 12 - .../htmlChartPluginLoaders/plugin01/chart.js | 6 - .../plugin01/{properties.json => plugin.js} | 3 +- .../htmlChartPluginLoaders/plugin02/chart.js | 6 - .../plugin02/{properties.json => plugin.js} | 3 +- .../html/htmlChartPluginLoaders/plugin03.zip | Bin 971 -> 754 bytes .../html/htmlChartPluginLoaders/plugin04.zip | Bin 972 -> 754 bytes .../html/htmlChartPluginTest/plugin.js | 37 ++ .../html/widget01/index.html | 2 +- .../java/org/datagear/util/i18n/Label.java | 3 + .../datagear-chart-bar-0.1.0/chart.js | 43 -- .../datagear-chart-bar-0.1.0/plugin.js | 56 +++ .../datagear-chart-bar-0.1.0/properties.json | 12 - .../datagear-chart-line-0.1.0/chart.js | 43 -- .../datagear-chart-line-0.1.0/plugin.js | 56 +++ .../datagear-chart-line-0.1.0/properties.json | 12 - .../datagear-chart-pie-0.1.0/chart.js | 60 --- .../datagear-chart-pie-0.1.0/plugin.js | 73 +++ .../datagear-chart-pie-0.1.0/properties.json | 12 - .../script/datagear-dashboard-renderer.js | 4 +- 42 files changed, 1380 insertions(+), 438 deletions(-) create mode 100644 datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolver.java create mode 100644 datagear-analysis/src/main/java/org/datagear/analysis/support/html/TextParserSupport.java create mode 100644 datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolverTest.java delete mode 100644 datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.chart.js delete mode 100644 datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.config.json delete mode 100644 datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/chart.js rename datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/{properties.json => plugin.js} (82%) delete mode 100644 datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/chart.js rename datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/{properties.json => plugin.js} (82%) create mode 100644 datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginTest/plugin.js delete mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/chart.js create mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/plugin.js delete mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/properties.json delete mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/chart.js create mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/plugin.js delete mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/properties.json delete mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/chart.js create mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/plugin.js delete mode 100644 datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/properties.json diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/ChartPlugin.java b/datagear-analysis/src/main/java/org/datagear/analysis/ChartPlugin.java index 45b4ed74..8d0bf0a6 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/ChartPlugin.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/ChartPlugin.java @@ -22,6 +22,16 @@ import org.datagear.util.i18n.Label; */ public interface ChartPlugin extends Identifiable { + String PROPERTY_ID = "id"; + String PROPERTY_NAME_LABEL = "nameLabel"; + String PROPERTY_DESC_LABEL = "descLabel"; + String PROPERTY_MANUAL_LABEL = "manualLabel"; + String PROPERTY_ICONS = "icons"; + String PROPERTY_CHART_PROPERTIES = "chartProperties"; + String PROPERTY_DATA_SIGNS = "dataSigns"; + String PROPERTY_VERSION = "version"; + String PROPERTY_ORDER = "order"; + /** * 获取名称标签。 * diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/ChartProperty.java b/datagear-analysis/src/main/java/org/datagear/analysis/ChartProperty.java index a551fce7..8ac4628e 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/ChartProperty.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/ChartProperty.java @@ -20,6 +20,13 @@ import org.datagear.util.i18n.Label; */ public class ChartProperty { + public static final String PROPERTY_NAME = "name"; + public static final String PROPERTY_TYPE = "type"; + public static final String PROPERTY_NAME_LABEL = "nameLabel"; + public static final String PROPERTY_DESC_LABEL = "descLabel"; + public static final String PROPERTY_DEFAULT_VALUE = "defaultValue"; + public static final String PROPERTY_CONSTRAINTS = "constraints"; + /** 名称 */ private String name; diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/Dashboard.java b/datagear-analysis/src/main/java/org/datagear/analysis/Dashboard.java index 46699ff9..7fb87ba6 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/Dashboard.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/Dashboard.java @@ -20,6 +20,11 @@ import java.util.Map; */ public class Dashboard extends AbstractIdentifiable { + public static final String PROPERTY_ID = "id"; + public static final String PROPERTY_RENDER_CONTEXT = "renderContext"; + public static final String PROPERTY_WIDGET = "widget"; + public static final String PROPERTY_CHARTS = "charts"; + private RenderContext renderContext; private DashboardWidget widget; diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/DashboardTheme.java b/datagear-analysis/src/main/java/org/datagear/analysis/DashboardTheme.java index 1796924a..e23d29a5 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/DashboardTheme.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/DashboardTheme.java @@ -14,6 +14,8 @@ public class DashboardTheme extends Theme { private static final long serialVersionUID = 1L; + public static final String PROPERTY_CHART_THEME = "chartTheme"; + private ChartTheme chartTheme; public DashboardTheme() diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/DataSign.java b/datagear-analysis/src/main/java/org/datagear/analysis/DataSign.java index ff108f6a..ee110dbf 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/DataSign.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/DataSign.java @@ -27,6 +27,12 @@ public class DataSign implements Serializable { private static final long serialVersionUID = 1L; + public static final String PROPERTY_NAME = "name"; + public static final String PROPERTY_OCCUR_REQUIRED = "occurRequired"; + public static final String PROPERTY_OCCUR_MULTIPLE = "occurMultiple"; + public static final String PROPERTY_NAME_LABEL = "nameLabel"; + public static final String PROPERTY_DESC_LABEL = "descLabel"; + /** 名称 */ private String name; diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/RenderContext.java b/datagear-analysis/src/main/java/org/datagear/analysis/RenderContext.java index ebaaf0f7..4151c0ac 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/RenderContext.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/RenderContext.java @@ -21,6 +21,8 @@ import java.util.Map; */ public interface RenderContext { + String PROPERTY_ATTRIBUTES = "attributes"; + /** * 获取属性。 * diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolver.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolver.java index e438b6da..86ba4a51 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolver.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolver.java @@ -69,52 +69,6 @@ import com.alibaba.fastjson.JSON; */ public class JsonChartPluginPropertiesResolver { - public static final String CHART_PLUGIN_ID = "id"; - - public static final String CHART_PLUGIN_NAME_LABEL = "nameLabel"; - - public static final String CHART_PLUGIN_DESC_LABEL = "descLabel"; - - public static final String CHART_PLUGIN_MANUAL_LABEL = "manualLabel"; - - public static final String CHART_PLUGIN_ICONS = "icons"; - - public static final String CHART_PLUGIN_CHART_PROPERTIES = "chartProperties"; - - public static final String CHART_PLUGIN_DATA_SIGNS = "dataSigns"; - - public static final String CHART_PLUGIN_VERSION = "version"; - - public static final String CHART_PLUGIN_ORDER = "order"; - - public static final String LABEL_VALUE = "value"; - - public static final String LABEL_LOCALE_VALUES = "localeValues"; - - public static final String LOCATION_ICON_LOCATION = "location"; - - public static final String CHART_PROPERTY_NAME = "name"; - - public static final String CHART_PROPERTY_TYPE = "type"; - - public static final String CHART_PROPERTY_NAME_LABEL = "nameLabel"; - - public static final String CHART_PROPERTY_DESC_LABEL = "descLabel"; - - public static final String CHART_PROPERTY_DEFAULT_VALUE = "defaultValue"; - - public static final String CHART_PROPERTY_CONSTRAINTS = "constraints"; - - public static final String DATA_SIGN_PROPERTY_NAME = "name"; - - public static final String DATA_SIGN_PROPERTY_OCCUR_REQUIRED = "occurRequired"; - - public static final String DATA_SIGN_PROPERTY_OCCUR_MULTIPLE = "occurMultiple"; - - public static final String DATA_SIGN_PROPERTY_NAME_LABEL = "nameLabel"; - - public static final String DATA_SIGN_PROPERTY_DESC_LABEL = "descLabel"; - private PropertyTypeValueConverter propertyTypeValueConverter = new PropertyTypeValueConverter(); private ConcurrentMap _localeCache = new ConcurrentHashMap(); @@ -150,12 +104,13 @@ public class JsonChartPluginPropertiesResolver Map properties = new HashMap(map); - properties.put(CHART_PLUGIN_NAME_LABEL, convertToLabel(map.get(CHART_PLUGIN_NAME_LABEL))); - properties.put(CHART_PLUGIN_DESC_LABEL, convertToLabel(map.get(CHART_PLUGIN_DESC_LABEL))); - properties.put(CHART_PLUGIN_MANUAL_LABEL, convertToLabel(map.get(CHART_PLUGIN_MANUAL_LABEL))); - properties.put(CHART_PLUGIN_ICONS, convertToIcons(map.get(CHART_PLUGIN_ICONS))); - properties.put(CHART_PLUGIN_CHART_PROPERTIES, convertToChartProperties(map.get(CHART_PLUGIN_CHART_PROPERTIES))); - properties.put(CHART_PLUGIN_DATA_SIGNS, convertToDataSigns(map.get(CHART_PLUGIN_DATA_SIGNS))); + properties.put(ChartPlugin.PROPERTY_NAME_LABEL, convertToLabel(map.get(ChartPlugin.PROPERTY_NAME_LABEL))); + properties.put(ChartPlugin.PROPERTY_DESC_LABEL, convertToLabel(map.get(ChartPlugin.PROPERTY_DESC_LABEL))); + properties.put(ChartPlugin.PROPERTY_MANUAL_LABEL, convertToLabel(map.get(ChartPlugin.PROPERTY_MANUAL_LABEL))); + properties.put(ChartPlugin.PROPERTY_ICONS, convertToIcons(map.get(ChartPlugin.PROPERTY_ICONS))); + properties.put(ChartPlugin.PROPERTY_CHART_PROPERTIES, + convertToChartProperties(map.get(ChartPlugin.PROPERTY_CHART_PROPERTIES))); + properties.put(ChartPlugin.PROPERTY_DATA_SIGNS, convertToDataSigns(map.get(ChartPlugin.PROPERTY_DATA_SIGNS))); return properties; } @@ -214,18 +169,18 @@ public class JsonChartPluginPropertiesResolver @SuppressWarnings("unchecked") public void setChartPluginProperties(AbstractChartPlugin chartPlugin, Map properties) { - chartPlugin.setId((String) properties.get(CHART_PLUGIN_ID)); - chartPlugin.setNameLabel((Label) properties.get(CHART_PLUGIN_NAME_LABEL)); - chartPlugin.setDescLabel((Label) properties.get(CHART_PLUGIN_DESC_LABEL)); - chartPlugin.setManualLabel((Label) properties.get(CHART_PLUGIN_MANUAL_LABEL)); - chartPlugin.setIcons((Map) properties.get(CHART_PLUGIN_ICONS)); - chartPlugin.setChartProperties((List) properties.get(CHART_PLUGIN_CHART_PROPERTIES)); - chartPlugin.setDataSigns((List) properties.get(CHART_PLUGIN_DATA_SIGNS)); - chartPlugin.setVersion((String) properties.get(CHART_PLUGIN_VERSION)); + chartPlugin.setId((String) properties.get(ChartPlugin.PROPERTY_ID)); + chartPlugin.setNameLabel((Label) properties.get(ChartPlugin.PROPERTY_NAME_LABEL)); + chartPlugin.setDescLabel((Label) properties.get(ChartPlugin.PROPERTY_DESC_LABEL)); + chartPlugin.setManualLabel((Label) properties.get(ChartPlugin.PROPERTY_MANUAL_LABEL)); + chartPlugin.setIcons((Map) properties.get(ChartPlugin.PROPERTY_ICONS)); + chartPlugin.setChartProperties((List) properties.get(ChartPlugin.PROPERTY_CHART_PROPERTIES)); + chartPlugin.setDataSigns((List) properties.get(ChartPlugin.PROPERTY_DATA_SIGNS)); + chartPlugin.setVersion((String) properties.get(ChartPlugin.PROPERTY_VERSION)); Integer order = null; - Object orderObj = properties.get(CHART_PLUGIN_ORDER); + Object orderObj = properties.get(ChartPlugin.PROPERTY_ORDER); if (orderObj instanceof Number) order = ((Number) orderObj).intValue(); else if (orderObj instanceof String) @@ -268,9 +223,9 @@ public class JsonChartPluginPropertiesResolver Map map = (Map) obj; Label label = createLabel(); - label.setValue((String) map.get(LABEL_VALUE)); + label.setValue((String) map.get(Label.PROPERTY_VALUE)); - Object localeValuesObj = map.get(LABEL_LOCALE_VALUES); + Object localeValuesObj = map.get(Label.PROPERTY_LOCALE_VALUES); if (localeValuesObj != null) { Map localeValues = new HashMap(); @@ -367,7 +322,7 @@ public class JsonChartPluginPropertiesResolver @SuppressWarnings("unchecked") Map map = (Map) obj; - String location = (String) map.get(LOCATION_ICON_LOCATION); + String location = (String) map.get(LocationIcon.PROPERTY_LOCATION); if (location == null) return null; @@ -455,22 +410,23 @@ public class JsonChartPluginPropertiesResolver @SuppressWarnings("unchecked") Map map = (Map) obj; - String name = (String) map.get(CHART_PROPERTY_NAME); + String name = (String) map.get(ChartProperty.PROPERTY_NAME); if (name == null || name.isEmpty()) return null; ChartProperty chartProperty = createChartProperty(); chartProperty.setName(name); - PropertyType type = convertToPropertyType(map.get(CHART_PROPERTY_TYPE)); + PropertyType type = convertToPropertyType(map.get(ChartProperty.PROPERTY_TYPE)); if (type == null) type = PropertyType.STRING; chartProperty.setType(type); - chartProperty.setNameLabel(convertToLabel(map.get(CHART_PROPERTY_NAME_LABEL))); - chartProperty.setDescLabel(convertToLabel(map.get(CHART_PROPERTY_DESC_LABEL))); - chartProperty.setDefaultValue(convertToPropertyTypeValue(type, map.get(CHART_PROPERTY_DEFAULT_VALUE))); - chartProperty.setConstraints(convertToConstraints(map.get(CHART_PROPERTY_CONSTRAINTS))); + chartProperty.setNameLabel(convertToLabel(map.get(ChartProperty.PROPERTY_NAME_LABEL))); + chartProperty.setDescLabel(convertToLabel(map.get(ChartProperty.PROPERTY_DESC_LABEL))); + chartProperty + .setDefaultValue(convertToPropertyTypeValue(type, map.get(ChartProperty.PROPERTY_DEFAULT_VALUE))); + chartProperty.setConstraints(convertToConstraints(map.get(ChartProperty.PROPERTY_CONSTRAINTS))); return chartProperty; } @@ -669,17 +625,17 @@ public class JsonChartPluginPropertiesResolver @SuppressWarnings("unchecked") Map map = (Map) obj; - String name = (String) map.get(DATA_SIGN_PROPERTY_NAME); + String name = (String) map.get(DataSign.PROPERTY_NAME); if (name == null || name.isEmpty()) return null; DataSign dataSign = createDataSign(); dataSign.setName(name); - dataSign.setOccurRequired(convertToBoolean(map.get(DATA_SIGN_PROPERTY_OCCUR_REQUIRED), true)); - dataSign.setOccurMultiple(convertToBoolean(map.get(DATA_SIGN_PROPERTY_OCCUR_MULTIPLE), true)); - dataSign.setNameLabel(convertToLabel(map.get(DATA_SIGN_PROPERTY_NAME_LABEL))); - dataSign.setDescLabel(convertToLabel(map.get(DATA_SIGN_PROPERTY_DESC_LABEL))); + dataSign.setOccurRequired(convertToBoolean(map.get(DataSign.PROPERTY_OCCUR_REQUIRED), true)); + dataSign.setOccurMultiple(convertToBoolean(map.get(DataSign.PROPERTY_OCCUR_MULTIPLE), true)); + dataSign.setNameLabel(convertToLabel(map.get(DataSign.PROPERTY_NAME_LABEL))); + dataSign.setDescLabel(convertToLabel(map.get(DataSign.PROPERTY_DESC_LABEL))); return dataSign; } diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/LocationIcon.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/LocationIcon.java index 854eacce..f101d2c7 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/LocationIcon.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/LocationIcon.java @@ -24,6 +24,8 @@ public class LocationIcon extends LocationResource implements Icon { private static final long serialVersionUID = 1L; + public static final String PROPERTY_LOCATION = "location"; + private String type = ""; private long lastModified = System.currentTimeMillis(); diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java index 39ef3a19..7683c255 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/DirectoryHtmlChartPluginManager.java @@ -438,7 +438,7 @@ public class DirectoryHtmlChartPluginManager extends ConcurrentChartPluginManage { HtmlChartPlugin htmlChartPlugin = (HtmlChartPlugin) chartPlugin; - if (htmlChartPlugin.getJsChartRenderer() == null) + if (htmlChartPlugin.getChartRenderer() == null) legal = false; } } diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPlugin.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPlugin.java index 366ba00b..41e204af 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPlugin.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPlugin.java @@ -102,6 +102,8 @@ import org.datagear.util.i18n.Label; */ public class HtmlChartPlugin extends AbstractChartPlugin { + public static final String PROPERTY_CHART_RENDER = "chartRender"; + /** HTML换行符 */ public static final String HTML_NEW_LINE = "\n"; @@ -113,7 +115,7 @@ public class HtmlChartPlugin extends AbstractChartP public static final String DEFAULT_SCRIPT_CHART_REF_PLACEHOLDER = "$CHART"; /** JS图表渲染器 */ - private JsChartRenderer jsChartRenderer; + private JsChartRenderer chartRenderer; /** 图表HTML元素标签名 */ private String elementTagName = "div"; @@ -126,20 +128,20 @@ public class HtmlChartPlugin extends AbstractChartP super(); } - public HtmlChartPlugin(String id, Label nameLabel, JsChartRenderer jsChartRenderer) + public HtmlChartPlugin(String id, Label nameLabel, JsChartRenderer chartRenderer) { super(id, nameLabel); - this.jsChartRenderer = jsChartRenderer; + this.chartRenderer = chartRenderer; } - public JsChartRenderer getJsChartRenderer() + public JsChartRenderer getChartRenderer() { - return jsChartRenderer; + return chartRenderer; } - public void setJsChartRenderer(JsChartRenderer jsChartRenderer) + public void setChartRenderer(JsChartRenderer chartRenderer) { - this.jsChartRenderer = jsChartRenderer; + this.chartRenderer = chartRenderer; } public String getElementTagName() @@ -256,9 +258,8 @@ public class HtmlChartPlugin extends AbstractChartP if (!optionInitialized.isNotWriteInvoke()) { - out.write( - optionInitialized.getPluginVarName() + "." + HtmlChartPluginScriptObjectWriter.JS_CHART_RENDER_NAME - + "." + JsChartRenderer.RENDER_FUNCTION_NAME + "(" + chart.getVarName() + ");"); + out.write(optionInitialized.getPluginVarName() + "." + PROPERTY_CHART_RENDER + "." + + JsChartRenderer.RENDER_FUNCTION_NAME + "(" + chart.getVarName() + ");"); writeNewLine(out); } } diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolver.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolver.java new file mode 100644 index 00000000..e6c0f787 --- /dev/null +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolver.java @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2018 datagear.tech. All Rights Reserved. + */ + +/** + * + */ +package org.datagear.analysis.support.html; + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; + +import org.datagear.util.IOUtil; + +/** + * {@linkplain HtmlChartPlugin}的JS定义格式解析器。 + *

+ * 支持的JS定义格式: + *

+ * + *
+ * {
+ * 	id: ...,
+ * 	nameLabel: ...,
+ * 	...,
+ * 	chartRender: {...},
+ * 	...
+ * }
+ * 
+ *
+ *

+ * 此类从上述格式的输入流解析{@linkplain JsDefContent}对象,其中: + *

+ *

+ * {@linkplain JsDefContent#getPluginJson()}为上述格式中将chartRender: {...}替换为chartRender: {}的内容。 + *

+ *

+ * {@linkplain JsDefContent#getPluginChartRender()}为上述格式中chartRender属性值部分的内容:{...} + *

+ * + * @author datagear@163.com + * + */ +public class HtmlChartPluginJsDefResolver extends TextParserSupport +{ + protected static final char PROPERTY_CHART_RENDER_FIRST = HtmlChartPlugin.PROPERTY_CHART_RENDER.charAt(0); + protected static final String PROPERTY_CHART_RENDER_DQ = "\"" + HtmlChartPlugin.PROPERTY_CHART_RENDER + "\""; + protected static final String PROPERTY_CHART_RENDER_SQ = "'" + HtmlChartPlugin.PROPERTY_CHART_RENDER + "'"; + + public HtmlChartPluginJsDefResolver() + { + super(); + } + + /** + * 解析。 + * + * @param str + * @return + * @throws IOException + */ + public JsDefContent resolve(String str) throws IOException + { + if (str == null) + str = ""; + + Reader reader = null; + + try + { + reader = IOUtil.getReader(str); + return resolve(reader); + } + finally + { + IOUtil.close(reader); + } + } + + /** + * 解析。 + * + * @param reader + * @return + * @throws IOException + */ + public JsDefContent resolve(Reader reader) throws IOException + { + StringBuilder jsonBuilder = new StringBuilder(); + StringBuilder chartRenderBuilder = new StringBuilder(); + + resolveJsDefContent(reader, jsonBuilder, chartRenderBuilder); + + return new JsDefContent(jsonBuilder.toString(), chartRenderBuilder.toString()); + } + + protected void resolveJsDefContent(Reader in, StringBuilder jsonBuilder, StringBuilder chartRenderBuilder) + throws IOException + { + StringBuilder token = createStringBuilder(); + + int c = in.read(); + while (c > -1) + { + appendChar(jsonBuilder, c); + + if (isWhitespace(c)) + { + c = in.read(); + } + else if (c == ':') + { + String tokenStr = token.toString(); + clear(token); + + if (tokenStr.equals(HtmlChartPlugin.PROPERTY_CHART_RENDER) || tokenStr.equals(PROPERTY_CHART_RENDER_DQ) + || tokenStr.equals(PROPERTY_CHART_RENDER_SQ)) + { + readChartRenderObjectContent(in, chartRenderBuilder); + jsonBuilder.append("{}"); + } + + c = in.read(); + } + else if (c == '{' || c == ',') + { + clear(token); + c = in.read(); + } + // 注释 + else if (c == '/') + { + c = in.read(); + + if (c == '/') + { + appendChar(jsonBuilder, c); + c = skipLineComment(in, jsonBuilder, false); + } + else if (c == '*') + { + appendChar(jsonBuilder, c); + c = skipBlockComment(in, jsonBuilder, false); + } + else + { + appendChar(token, '/'); + appendCharIfValid(token, c); + } + } + // 字符串 + else if (c == '\'' || c == '"') + { + appendChar(token, c); + c = readQuoted(in, token, c); + + jsonBuilder.append(token.substring(1)); + } + else + { + appendChar(token, c); + c = in.read(); + } + } + } + + /** + * 从{之前的位置开始读取{@linkplain JsChartRenderer}内容。 + *

+ * 读取停止位置为:} + *

+ * + * @param in + * @param chartRenderBuilder + * @throws IOException + */ + protected void readChartRenderObjectContent(Reader in, StringBuilder chartRenderBuilder) throws IOException + { + int qcount = 0; + + int c = -1; + while ((c = in.read()) > -1) + { + appendChar(chartRenderBuilder, c); + + if (c == '{') + { + qcount++; + } + else if (c == '}') + { + qcount--; + + if (qcount == 0) + break; + } + // 字符串 + else if (c == '\'' || c == '"') + { + c = readQuoted(in, chartRenderBuilder, c); + appendCharIfValid(chartRenderBuilder, c); + } + // 注释 + else if (c == '/') + { + int next = in.read(); + appendCharIfValid(chartRenderBuilder, next); + + // 行注释 + if (next == '/') + skipLineComment(in, chartRenderBuilder, true); + else if (next == '*') + skipBlockComment(in, chartRenderBuilder, true); + } + } + } + + public static class JsDefContent implements Serializable + { + private static final long serialVersionUID = 1L; + + /** 插件定义JSON */ + private String pluginJson; + + /** 插件JS渲染器对象内容 */ + private String pluginChartRender; + + public JsDefContent() + { + super(); + } + + public JsDefContent(String pluginJson, String pluginChartRender) + { + super(); + this.pluginJson = pluginJson; + this.pluginChartRender = pluginChartRender; + } + + public String getPluginJson() + { + return pluginJson; + } + + public void setPluginJson(String pluginJson) + { + this.pluginJson = pluginJson; + } + + public String getPluginChartRender() + { + return pluginChartRender; + } + + public void setPluginChartRender(String pluginChartRender) + { + this.pluginChartRender = pluginChartRender; + } + + @Override + public String toString() + { + return getClass().getSimpleName() + " [pluginJson=" + pluginJson + ", pluginChartRender=" + + pluginChartRender + "]"; + } + } +} diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginLoader.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginLoader.java index 7bf038c1..2e028447 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginLoader.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginLoader.java @@ -10,6 +10,7 @@ package org.datagear.analysis.support.html; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.Reader; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -22,6 +23,7 @@ import org.datagear.analysis.RenderStyle; import org.datagear.analysis.support.BytesIcon; import org.datagear.analysis.support.JsonChartPluginPropertiesResolver; import org.datagear.analysis.support.LocationIcon; +import org.datagear.analysis.support.html.HtmlChartPluginJsDefResolver.JsDefContent; import org.datagear.util.FileUtil; import org.datagear.util.IOUtil; import org.datagear.util.StringUtil; @@ -36,15 +38,25 @@ import org.datagear.util.StringUtil; *

* *
- * |---- properties.json
- * |---- chart.js
+ * |---- plugin.js
  * 
*
*

- * properties.json用于定义{@linkplain HtmlChartPlugin}本身的属性。 + * 上述文件格式规范如下: *

+ * + *
+ * {
+ * 	id : "...",
+ * 	nameLabel : { value : "...", localeValues : { "zh" : "...", "en" : "..." }},
+ * 	...,
+ * 	chartRender: { ... },
+ * 	...
+ * }
+ * 
+ *
*

- * 如果properties.json中定义了插件图标,比如: + * 如果plugin.js中定义了插件图标,比如: *

*

* icons : { "LIGHT" : "icons/light.png" } @@ -52,10 +64,10 @@ import org.datagear.util.StringUtil; *

* ,那么上述文件结构中还应有icons/light.png文件。 *

- * chart.js用于定义{@linkplain HtmlChartPlugin}的图表渲染逻辑。 + * chartRender用于定义{@linkplain HtmlChartPlugin#getChartRenderer()}内容。 *

*

- * 默认地,上述两个文件都应该为UTF-8编码。 + * 默认地,上述文件应该为UTF-8编码。 *

* * @author datagear@163.com @@ -63,9 +75,9 @@ import org.datagear.util.StringUtil; */ public class HtmlChartPluginLoader { - public static final String NAME_PROPERTIES = "properties.json"; + public static final String FILE_NAME_PLUGIN = "plugin.js"; - public static final String NAME_CHART = "chart.js"; + private HtmlChartPluginJsDefResolver htmlChartPluginJsDefResolver = new HtmlChartPluginJsDefResolver(); private JsonChartPluginPropertiesResolver jsonChartPluginPropertiesResolver = new JsonChartPluginPropertiesResolver(); @@ -77,6 +89,16 @@ public class HtmlChartPluginLoader super(); } + public HtmlChartPluginJsDefResolver getHtmlChartPluginJsDefResolver() + { + return htmlChartPluginJsDefResolver; + } + + public void setHtmlChartPluginJsDefResolver(HtmlChartPluginJsDefResolver htmlChartPluginJsDefResolver) + { + this.htmlChartPluginJsDefResolver = htmlChartPluginJsDefResolver; + } + public JsonChartPluginPropertiesResolver getJsonChartPluginPropertiesResolver() { return jsonChartPluginPropertiesResolver; @@ -109,10 +131,9 @@ public class HtmlChartPluginLoader if (!directory.exists()) return false; - File propFile = new File(directory, NAME_PROPERTIES); - File chartFile = new File(directory, NAME_CHART); + File pluginFile = new File(directory, FILE_NAME_PLUGIN); - return (propFile.exists() && chartFile.exists()); + return (pluginFile.exists()); } /** @@ -165,11 +186,7 @@ public class HtmlChartPluginLoader if (zipEntry.isDirectory()) ; - else if (name.equals(NAME_PROPERTIES)) - { - yes += 1; - } - else if (name.equals(NAME_CHART)) + else if (name.equals(FILE_NAME_PLUGIN)) { yes += 1; } @@ -182,7 +199,7 @@ public class HtmlChartPluginLoader throw new HtmlChartPluginLoadException(e); } - return (yes >= 2); + return (yes >= 1); } /** @@ -326,32 +343,34 @@ public class HtmlChartPluginLoader protected HtmlChartPlugin loadSingleForDirectory(File directory) throws HtmlChartPluginLoadException { - File propFile = new File(directory, NAME_PROPERTIES); - File chartFile = new File(directory, NAME_CHART); + File chartFile = new File(directory, FILE_NAME_PLUGIN); - if (!propFile.exists() || !chartFile.exists()) + if (!chartFile.exists()) return null; HtmlChartPlugin plugin = null; - InputStream propIn = null; - InputStream chartIn = null; + Reader chartIn = null; try { - propIn = IOUtil.getInputStream(propFile); - chartIn = IOUtil.getInputStream(chartFile); + chartIn = IOUtil.getReader(chartFile, this.encoding); - Map properties = this.jsonChartPluginPropertiesResolver.resolveChartPluginProperties(propIn, - this.encoding); - String scriptContent = readScriptContent(chartIn, false); + JsDefContent jsDefContent = this.htmlChartPluginJsDefResolver.resolve(chartIn); - plugin = createHtmlChartPlugin(); + if (!StringUtil.isEmpty(jsDefContent.getPluginJson()) + && !StringUtil.isEmpty(jsDefContent.getPluginChartRender())) + { + Map properties = this.jsonChartPluginPropertiesResolver + .resolveChartPluginProperties(jsDefContent.getPluginJson()); - this.jsonChartPluginPropertiesResolver.setChartPluginProperties(plugin, properties); - plugin.setJsChartRenderer(new StringJsChartRenderer(scriptContent)); + plugin = createHtmlChartPlugin(); - plugin.setIcons(toBytesIconsInDirectory(directory, plugin.getIcons())); + this.jsonChartPluginPropertiesResolver.setChartPluginProperties(plugin, properties); + plugin.setChartRenderer(new StringJsChartRenderer(jsDefContent.getPluginChartRender())); + + plugin.setIcons(toBytesIconsInDirectory(directory, plugin.getIcons())); + } } catch (Exception e) { @@ -359,7 +378,6 @@ public class HtmlChartPluginLoader } finally { - IOUtil.close(propIn); IOUtil.close(chartIn); } diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginScriptObjectWriter.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginScriptObjectWriter.java index cc0a7825..3e422903 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginScriptObjectWriter.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlChartPluginScriptObjectWriter.java @@ -28,8 +28,6 @@ import org.datagear.util.IOUtil; */ public class HtmlChartPluginScriptObjectWriter extends AbstractHtmlScriptObjectWriter { - public static final String JS_CHART_RENDER_NAME = "jsChartRender"; - public HtmlChartPluginScriptObjectWriter() { super(); @@ -44,7 +42,7 @@ public class HtmlChartPluginScriptObjectWriter extends AbstractHtmlScriptObjectW *
 	 * var [varName]=
 	 * { ... };
-	 * [varName].jsChartRender=
+	 * [varName].chartRender=
 	 * {...};
 	 * 
 	 * 
@@ -63,7 +61,7 @@ public class HtmlChartPluginScriptObjectWriter extends AbstractHtmlScriptObjectW
 		writeJsonObject(out, jsonPlugin);
 		out.write(";");
 		writeNewLine(out);
-		writeJsChartRender(out, plugin, varName);
+		writeHtmlChartRender(out, plugin, varName);
 	}
 
 	/**
@@ -73,14 +71,14 @@ public class HtmlChartPluginScriptObjectWriter extends AbstractHtmlScriptObjectW
 	 * @param chart
 	 * @throws IOException
 	 */
-	protected void writeJsChartRender(Writer out, HtmlChartPlugin plugin, String varName) throws IOException
+	protected void writeHtmlChartRender(Writer out, HtmlChartPlugin plugin, String varName) throws IOException
 	{
-		out.write(varName + "." + JS_CHART_RENDER_NAME + "=");
+		out.write(varName + "." + HtmlChartPlugin.PROPERTY_CHART_RENDER + "=");
 		writeNewLine(out);
 
-		JsChartRenderer jsChartRenderer = plugin.getJsChartRenderer();
+		JsChartRenderer chartRenderer = plugin.getChartRenderer();
 
-		Reader reader = jsChartRenderer.getReader();
+		Reader reader = chartRenderer.getReader();
 
 		try
 		{
diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetFmkRenderer.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetFmkRenderer.java
index dd202e1b..578aacd6 100644
--- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetFmkRenderer.java
+++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetFmkRenderer.java
@@ -206,6 +206,28 @@ public class HtmlTplDashboardWidgetFmkRenderer exte
 		return dataModel;
 	}
 
+	/**
+	 * 设置用于渲染Freemark看板图表的{@linkplain HtmlChartPluginRenderOption}。
+	 * 
+	 * @param renderContext
+	 * @param dashboardVarName
+	 * @return
+	 */
+	protected HtmlChartPluginRenderOption setHtmlChartPluginRenderOption(RenderContext renderContext,
+			String dashboardVarName)
+	{
+		HtmlChartPluginRenderOption option = new HtmlChartPluginRenderOption();
+		option.setNotWriteChartElement(false);
+		option.setNotWriteScriptTag(false);
+		option.setNotWriteInvoke(true);
+		option.setNotWriteRenderContextObject(true);
+		option.setRenderContextVarName(dashboardVarName + ".renderContext");
+
+		HtmlChartPluginRenderOption.setOption(renderContext, option);
+
+		return option;
+	}
+
 	/**
 	 * HTML看板渲染数据模型。
 	 * 
@@ -401,28 +423,6 @@ public class HtmlTplDashboardWidgetFmkRenderer exte
 		}
 	}
 
-	/**
-	 * 设置用于渲染Freemark看板图表的{@linkplain HtmlChartPluginRenderOption}。
-	 * 
-	 * @param renderContext
-	 * @param dashboardVarName
-	 * @return
-	 */
-	protected HtmlChartPluginRenderOption setHtmlChartPluginRenderOption(RenderContext renderContext,
-			String dashboardVarName)
-	{
-		HtmlChartPluginRenderOption option = new HtmlChartPluginRenderOption();
-		option.setNotWriteChartElement(false);
-		option.setNotWriteScriptTag(false);
-		option.setNotWriteInvoke(true);
-		option.setNotWriteRenderContextObject(true);
-		option.setRenderContextVarName(dashboardVarName + ".renderContext");
-
-		HtmlChartPluginRenderOption.setOption(renderContext, option);
-
-		return option;
-	}
-
 	/**
 	 * “@chart”指令。
 	 * 
@@ -461,7 +461,7 @@ public class HtmlTplDashboardWidgetFmkRenderer exte
 			option.setChartElementId(elementId);
 			option.setChartVarName(var);
 
-			HtmlChart chart = chartWidget.render(renderContext);
+			HtmlChart chart = writeHtmlChart(chartWidget, renderContext);
 
 			List charts = htmlDashboard.getCharts();
 			if (charts == null)
diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetHtmlRenderer.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetHtmlRenderer.java
index 762f45e2..1d6f0e38 100644
--- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetHtmlRenderer.java
+++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetHtmlRenderer.java
@@ -387,7 +387,7 @@ public class HtmlTplDashboardWidgetHtmlRenderer ext
 				option.setPluginVarName(chartPluginVarNames.get(i));
 				option.setChartVarName(chartVarName);
 
-				HtmlChart chart = chartWidget.render(renderContext);
+				HtmlChart chart = writeHtmlChart(chartWidget, renderContext);
 				charts.add(chart);
 			}
 
diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetRenderer.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetRenderer.java
index 9e7a0fea..7e696da1 100644
--- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetRenderer.java
+++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/HtmlTplDashboardWidgetRenderer.java
@@ -21,6 +21,7 @@ import org.datagear.analysis.ChartTheme;
 import org.datagear.analysis.Dashboard;
 import org.datagear.analysis.DashboardTheme;
 import org.datagear.analysis.DashboardThemeSource;
+import org.datagear.analysis.RenderContext;
 import org.datagear.analysis.RenderException;
 import org.datagear.analysis.RenderStyle;
 import org.datagear.analysis.Theme;
@@ -91,6 +92,10 @@ public abstract class HtmlTplDashboardWidgetRenderer htmlChartPluginForNotFound = new ValueHtmlChartPlugin(
-			StringUtil.firstLowerCase(Global.PRODUCT_NAME_EN) + "HtmlChartPluginForNotFound");
+			StringUtil.firstLowerCase(Global.PRODUCT_NAME_EN) + "HtmlChartPluginForNotFound",
+			PROPERTY_VALUE_FOR_NOT_FOUND);
+
+	private HtmlChartPlugin htmlChartPluginForRenderException = new ValueHtmlChartPlugin(
+			StringUtil.firstLowerCase(Global.PRODUCT_NAME_EN) + "HtmlChartPluginForRenderException",
+			PROPERTY_VALUE_FOR_RENDER_EXCEPTION);
 
 	/** 内置导入内容 */
 	private List dashboardImports;
@@ -224,6 +234,17 @@ public abstract class HtmlTplDashboardWidgetRenderer getHtmlChartPluginForRenderException()
+	{
+		return htmlChartPluginForRenderException;
+	}
+
+	public void setHtmlChartPluginForRenderException(
+			HtmlChartPlugin htmlChartPluginForRenderException)
+	{
+		this.htmlChartPluginForRenderException = htmlChartPluginForRenderException;
+	}
+
 	public List getDashboardImports()
 	{
 		return dashboardImports;
@@ -658,7 +679,7 @@ public abstract class HtmlTplDashboardWidgetRenderer widget = new HtmlChartWidget(IDUtil.uuid(),
 				"HtmlChartWidgetForNotFound", this.htmlChartPluginForNotFound);
 
-		widget.addChartPropertyValue(ValueHtmlChartPlugin.VALUE_CHART_PROPERTY_NAME,
+		widget.addChartPropertyValue(PROPERTY_VALUE_FOR_NOT_FOUND,
 				"Chart '" + (notFoundWidgetId == null ? "" : notFoundWidgetId) + "' Not Found");
 
 		return widget;
@@ -721,10 +742,13 @@ public abstract class HtmlTplDashboardWidgetRenderer chartWidget,
+			HtmlRenderContext renderContext) throws RenderException
+	{
+		return chartWidget.render(renderContext);
+	}
+
 	/**
 	 * 写看板主题样式。
 	 * 
diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/TextParserSupport.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/TextParserSupport.java
new file mode 100644
index 00000000..331a2a65
--- /dev/null
+++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/TextParserSupport.java
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2018 datagear.tech. All Rights Reserved.
+ */
+
+/**
+ * 
+ */
+package org.datagear.analysis.support.html;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * 文本解析支持类。
+ * 
+ * @author datagear@163.com
+ *
+ */
+public class TextParserSupport
+{
+	public TextParserSupport()
+	{
+		super();
+	}
+
+	/**
+	 * 读取最多指定字符数的字符串。
+	 * 
+	 * @param reader
+	 * @param count
+	 * @return
+	 * @throws IOException
+	 */
+	public String readString(Reader reader, int count) throws IOException
+	{
+		char[] chars = new char[count];
+
+		int readed = reader.read(chars);
+
+		return new String(chars, 0, readed);
+	}
+
+	/**
+	 * 读取最多指定字符。
+	 * 
+	 * @param reader
+	 * @param cache
+	 * @param count
+	 * @return
+	 * @throws IOException
+	 */
+	public void readChars(Reader reader, StringBuilder cache, int count) throws IOException
+	{
+		for (int i = 0; i < count; i++)
+		{
+			int c = reader.read();
+
+			if (isValidReadChar(c))
+				appendChar(cache, c);
+			else
+				break;
+		}
+	}
+
+	/**
+	 * 读取到{@code '}或者{@code "}引号的下一个字符。
+	 * 

+ * 下一个字符不会写入{@code quoted}。 + *

+ * + * @param in + * @param quoted + * @param quote + * {@code '}或者{@code "} + * @return 引号的下一个字符、-1 + * @throws IOException + */ + public int readQuoted(Reader in, StringBuilder quoted, int quote) throws IOException + { + int c = -1; + boolean inEscape = false; + + while ((c = in.read()) > -1) + { + appendChar(quoted, c); + + if (inEscape) + inEscape = false; + else + { + if (c == '\\') + inEscape = true; + else if (c == quote) + break; + } + } + + if (c == quote) + c = in.read(); + + return c; + } + + /** + * 读取到{@linkplain Predicate#test(char)}为{@code false}。 + * + * @param in + * @param out + * 读取字符写入缓存,为{@code null}则不写入 + * @param predicate + * @param appendLast + * 结束字符是否也写入缓存 + * @return + * @throws IOException + */ + public int readUntil(Reader in, StringBuilder out, Predicate predicate, boolean appendLast) throws IOException + { + int c = -1; + + while ((c = in.read()) > -1) + { + if (predicate.test(c)) + appendCharIfNotNull(out, c); + else + { + if (appendLast) + appendCharIfNotNull(out, c); + + break; + } + } + + return c; + } + + /** + * 跳过空格或者注释。 + * + * @param in + * @param out + * 读取字符写入缓存,为{@code null}则不写入 + * @param appendLast + * 结束字符是否也写入缓存 + * @return 非空格或注释的内容、空字符串 + * @throws IOException + */ + public String skipWhitespaceOrBlockLineComment(Reader in, StringBuilder out, boolean appendLast) throws IOException + { + int c = skipWhitespace(in, out, false); + + if (c == -1) + return new String(""); + else if (c == '/') + { + int next = in.read(); + + boolean isComment = false; + + // 行注释 + if (next == '/') + { + appendCharIfNotNull(out, c); + appendCharIfNotNull(out, next); + c = skipLineComment(in, out, false); + isComment = true; + } + // 块注释 + else if (next == '*') + { + appendCharIfNotNull(out, c); + appendCharIfNotNull(out, next); + c = skipBlockComment(in, out, false); + isComment = true; + } + + if (isComment) + { + if (isWhitespace(c)) + { + appendCharIfNotNull(out, c); + return skipWhitespaceOrBlockLineComment(in, out, appendLast); + } + else + { + if (appendLast) + appendCharIfNotNull(out, c); + + StringBuilder sb = new StringBuilder(); + appendChar(sb, c); + + return sb.toString(); + } + } + else + { + if (appendLast) + appendCharIfNotNull(out, c); + + StringBuilder sb = new StringBuilder(); + appendChar(sb, c); + + if (isValidReadChar(next)) + appendChar(sb, next); + + return sb.toString(); + } + } + else + { + if (appendLast) + appendCharIfNotNull(out, c); + + StringBuilder sb = new StringBuilder(); + appendChar(sb, c); + + return sb.toString(); + } + } + + /** + * 读取到行注释“//”结束。 + * + * @param in + * @param out + * 读取字符写入缓存,为{@code null}则不写入 + * @param appendLast + * 结束字符是否也写入缓存 + * @return 注释结束符的下一个字符、-1 + * @throws IOException + */ + public int skipLineComment(Reader in, StringBuilder out, boolean appendLast) throws IOException + { + int c = -1; + + while ((c = in.read()) > -1) + { + appendCharIfNotNull(out, c); + + if (c == '\n') + break; + } + + if (c == '\n') + { + c = in.read(); + + if (appendLast) + appendCharIfValid(out, c); + } + + return c; + } + + /** + * 读取到块注释“*/”结束。 + * + * @param in + * @param out + * 读取字符写入缓存,为{@code null}则不写入 + * @param appendLast + * 结束字符是否也写入缓存 + * @return 注释结束的下一个字符、-1 + * @throws IOException + */ + public int skipBlockComment(Reader in, StringBuilder out, boolean appendLast) throws IOException + { + int c = -1; + + while ((c = in.read()) > -1) + { + appendCharIfNotNull(out, c); + + if (c == '/') + { + int len = out.length(); + int prev = (len > 1 ? out.charAt(len - 2) : -1); + + if (prev == '*') + break; + } + } + + if (c == '/') + { + c = in.read(); + + if (appendLast) + appendCharIfValid(out, c); + } + + return c; + } + + /** + * 读取到非空格。 + * + * @param in + * @param out + * 读取字符写入缓存,为{@code null}则不写入 + * @param appendLast + * 结束字符是否也写入缓存 + * @return 非空格字符、-1 + * @throws IOException + */ + public int skipWhitespace(Reader in, StringBuilder out, boolean appendLast) throws IOException + { + int c = -1; + + while ((c = in.read()) > -1) + { + if (isWhitespace(c)) + appendCharIfNotNull(out, c); + else + { + if (appendLast) + appendCharIfNotNull(out, c); + + break; + } + } + + return c; + } + + /** + * 追加字符。 + * + * @param sb + * @param c + */ + public void appendChar(StringBuilder sb, int c) + { + sb.appendCodePoint(c); + } + + /** + * 追加字符。 + *

+ * 如果{@code sb}为{@code null},则什么也不做并返回{@code false}。 + *

+ * + * @param sb + * @param c + * @return + */ + public boolean appendCharIfNotNull(StringBuilder sb, int c) + { + if (sb == null) + return false; + + sb.appendCodePoint(c); + return true; + } + + /** + * 追加字符。 + *

+ * 如果{@code sb}为{@code null}或者{@code c}不是合法字符,则什么也不做并返回{@code false}。 + *

+ * + * @param sb + * @param c + * @return + */ + public boolean appendCharIfValid(StringBuilder sb, int c) + { + if (sb == null) + return false; + + if (!isValidReadChar(c)) + return false; + + sb.appendCodePoint(c); + return true; + } + + /** + * 是否是有效的读取字符。 + * + * @param c + * @return + */ + public boolean isValidReadChar(int c) + { + return c > -1; + } + + /** + * 是否空格字符。 + * + * @param c + * @return + */ + public boolean isWhitespace(int c) + { + return Character.isWhitespace(c); + } + + /** + * 删除末尾字符。 + * + * @param sb + * @param count + */ + public void deleteTail(StringBuilder sb, int count) + { + int len = sb.length(); + + sb.delete(len - count, len); + } + + /** + * 清除{@linkplain StringBuilder}。 + * + * @param sb + */ + public void clear(StringBuilder sb) + { + if (sb == null) + return; + + sb.delete(0, sb.length()); + } + + public StringBuilder createStringBuilder() + { + return new StringBuilder(); + } + + public static interface Predicate + { + /** + * 判断字符是否合法。 + * + * @param c + * @return + */ + boolean test(int c); + } + + public static class WhitespacePredicate implements Predicate + { + @Override + public boolean test(int c) + { + return Character.isWhitespace(c); + } + } + + public static class NotWhitespacePredicate implements Predicate + { + @Override + public boolean test(int c) + { + return !Character.isWhitespace(c); + } + } +} diff --git a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/ValueHtmlChartPlugin.java b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/ValueHtmlChartPlugin.java index 93d823af..ae5ae38e 100644 --- a/datagear-analysis/src/main/java/org/datagear/analysis/support/html/ValueHtmlChartPlugin.java +++ b/datagear-analysis/src/main/java/org/datagear/analysis/support/html/ValueHtmlChartPlugin.java @@ -12,12 +12,13 @@ import java.util.Map; import org.datagear.analysis.ChartDataSet; import org.datagear.analysis.RenderException; +import org.datagear.util.StringUtil; import org.datagear.util.i18n.Label; /** * 仅渲染指定内容值的{@linkplain HtmlChartPlugin}。 *

- * 它从{@linkplain HtmlRenderContext}中获取{@linkplain #getValueAttributeName()}的属性值,并将其作为图表内容渲染。 + * 它从{@code chartPropertyValues}中获取{@linkplain #getValueChartPropertyName()}的属性值,并将其作为图表内容渲染。 *

* * @author datagear@163.com @@ -25,36 +26,43 @@ import org.datagear.util.i18n.Label; */ public class ValueHtmlChartPlugin extends HtmlChartPlugin { - public static final String VALUE_CHART_PROPERTY_NAME = "valueHtmlChartPluginValue"; - - protected static final StringJsChartRenderer JS_CHART_RENDERER = new StringJsChartRenderer( - "{" + HtmlChartPlugin.HTML_NEW_LINE + - // - " render : function(chart)" + HtmlChartPlugin.HTML_NEW_LINE + - // - " {" + HtmlChartPlugin.HTML_NEW_LINE + - // - " var element = document.getElementById(chart.elementId);" + HtmlChartPlugin.HTML_NEW_LINE + - // - " var propertyValues = (chart.propertyValues || {});" + HtmlChartPlugin.HTML_NEW_LINE + - // - " element.innerHTML=propertyValues['" + VALUE_CHART_PROPERTY_NAME + "'];" - + HtmlChartPlugin.HTML_NEW_LINE + - // - " }," + HtmlChartPlugin.HTML_NEW_LINE + - // - " update : function(){}" + HtmlChartPlugin.HTML_NEW_LINE + - // - "}"); + private String valueChartPropertyName; public ValueHtmlChartPlugin() { super(); } - public ValueHtmlChartPlugin(String id) + public ValueHtmlChartPlugin(String id, String valueChartPropertyName) { - super(id, new Label("ValueHtmlChartPlugin"), JS_CHART_RENDERER); + super(); + super.setId(id); + super.setNameLabel(new Label("ValueHtmlChartPlugin")); + super.setChartRenderer(buildJsChartRenderer(valueChartPropertyName)); + this.valueChartPropertyName = valueChartPropertyName; + } + + public String getValueChartPropertyName() + { + return valueChartPropertyName; + } + + public void setValueChartPropertyName(String valueChartPropertyName) + { + this.valueChartPropertyName = valueChartPropertyName; + super.setChartRenderer(buildJsChartRenderer(valueChartPropertyName)); + } + + @Override + public JsChartRenderer getChartRenderer() + { + return super.getChartRenderer(); + } + + @Override + public void setChartRenderer(JsChartRenderer chartRenderer) + { + throw new UnsupportedOperationException(); } @Override @@ -68,4 +76,27 @@ public class ValueHtmlChartPlugin extends HtmlChart return super.renderChart(renderContext, myChartPropertyValues, chartDataSets); } + + protected StringJsChartRenderer buildJsChartRenderer(String valueChartPropertyName) + { + return new StringJsChartRenderer("{" + HtmlChartPlugin.HTML_NEW_LINE + // + + " render : function(chart)" + HtmlChartPlugin.HTML_NEW_LINE + // + + " {" + HtmlChartPlugin.HTML_NEW_LINE + + // + " var element = document.getElementById(chart.elementId);" + HtmlChartPlugin.HTML_NEW_LINE + // + + " var propertyValues = (chart.propertyValues || {});" + HtmlChartPlugin.HTML_NEW_LINE + // + + " element.innerHTML=propertyValues['" + + StringUtil.escapeJavaScriptStringValue(valueChartPropertyName) + "'];" + HtmlChartPlugin.HTML_NEW_LINE + + // + + " }," + HtmlChartPlugin.HTML_NEW_LINE + // + + " update : function(){}" + HtmlChartPlugin.HTML_NEW_LINE + // + + "}"); + } } diff --git a/datagear-analysis/src/test/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolverTest.java b/datagear-analysis/src/test/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolverTest.java index 05473052..124266d8 100644 --- a/datagear-analysis/src/test/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolverTest.java +++ b/datagear-analysis/src/test/java/org/datagear/analysis/support/JsonChartPluginPropertiesResolverTest.java @@ -9,6 +9,7 @@ import java.util.Set; import org.datagear.analysis.Chart; import org.datagear.analysis.ChartDataSet; +import org.datagear.analysis.ChartPlugin; import org.datagear.analysis.ChartProperty; import org.datagear.analysis.DataSign; import org.datagear.analysis.PropertyType; @@ -45,24 +46,24 @@ public class JsonChartPluginPropertiesResolverTest Map properties = jsonChartPluginPropertiesResolver .resolveChartPluginProperties(jsonInputStream, "UTF-8"); - Assert.assertEquals("pie-chart", properties.get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_ID)); + Assert.assertEquals("pie-chart", properties.get(ChartPlugin.PROPERTY_ID)); { - Label nameLabel = (Label) properties.get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_NAME_LABEL); + Label nameLabel = (Label) properties.get(ChartPlugin.PROPERTY_NAME_LABEL); Assert.assertEquals("饼图", nameLabel.getValue()); Assert.assertEquals("pie chart", nameLabel.getValue(Label.toLocale("en"))); Assert.assertEquals("饼图中文", nameLabel.getValue(Label.toLocale("zh"))); } { - Label descLabel = (Label) properties.get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_DESC_LABEL); + Label descLabel = (Label) properties.get(ChartPlugin.PROPERTY_DESC_LABEL); Assert.assertEquals("饼图描述", descLabel.getValue()); Assert.assertEquals("pie chart desc", descLabel.getValue(Label.toLocale("en"))); Assert.assertEquals("饼图描述中文", descLabel.getValue(Label.toLocale("zh"))); } { - Label manualLabel = (Label) properties.get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_MANUAL_LABEL); + Label manualLabel = (Label) properties.get(ChartPlugin.PROPERTY_MANUAL_LABEL); Assert.assertEquals("饼图指南", manualLabel.getValue()); Assert.assertEquals("pie chart manual", manualLabel.getValue(Label.toLocale("en"))); Assert.assertEquals("饼图指南中文", manualLabel.getValue(Label.toLocale("zh"))); @@ -71,7 +72,7 @@ public class JsonChartPluginPropertiesResolverTest { @SuppressWarnings("unchecked") Map icons = (Map) properties - .get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_ICONS); + .get(ChartPlugin.PROPERTY_ICONS); Assert.assertEquals("icon-0.png", icons.get(RenderStyle.LIGHT).getLocation()); Assert.assertEquals("icon-1.png", icons.get(RenderStyle.DARK).getLocation()); @@ -79,7 +80,7 @@ public class JsonChartPluginPropertiesResolverTest @SuppressWarnings("unchecked") List chartProperties = (List) properties - .get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_CHART_PROPERTIES); + .get(ChartPlugin.PROPERTY_CHART_PROPERTIES); { ChartProperty chartProperty = chartProperties.get(0); @@ -134,8 +135,7 @@ public class JsonChartPluginPropertiesResolverTest } @SuppressWarnings("unchecked") - List dataSigns = (List) properties - .get(JsonChartPluginPropertiesResolver.CHART_PLUGIN_DATA_SIGNS); + List dataSigns = (List) properties.get(ChartPlugin.PROPERTY_DATA_SIGNS); { DataSign dataSign = dataSigns.get(0); diff --git a/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolverTest.java b/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolverTest.java new file mode 100644 index 00000000..29e8cb99 --- /dev/null +++ b/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginJsDefResolverTest.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2018 datagear.tech. All Rights Reserved. + */ + +/** + * + */ +package org.datagear.analysis.support.html; + +import java.io.IOException; + +import org.datagear.analysis.support.html.HtmlChartPluginJsDefResolver.JsDefContent; +import org.junit.Assert; +import org.junit.Test; + +/** + * {@linkplain HtmlChartPluginJsDefResolver}单元测试类。 + * + * @author datagear@163.com + * + */ +public class HtmlChartPluginJsDefResolverTest +{ + private HtmlChartPluginJsDefResolver resolver = new HtmlChartPluginJsDefResolver(); + + @Test + public void resolveTest() throws IOException + { + // 无引号 + { + String text = "{a: 'a', b : 'b', chartRender:{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', chartRender:{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{a: 'a', chartRender:{render:function() {}}, b : 'b'}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', chartRender:{}, b : 'b'}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{chartRender:{render:function() {}}, a: 'a', b : 'b'}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{chartRender:{}, a: 'a', b : 'b'}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + + // 单引号 + { + String text = "{a: 'a', b : 'b', 'chartRender':{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', 'chartRender':{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{a: 'a', 'chartRender':{render:function() {}}, b : 'b'}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', 'chartRender':{}, b : 'b'}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{'chartRender':{render:function() {}}, a: 'a', b : 'b'}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{'chartRender':{}, a: 'a', b : 'b'}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + + // 双引号 + { + String text = "{a: 'a', b : 'b', \"chartRender\":{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', \"chartRender\":{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{a: 'a', \"chartRender\":{render:function() {}}, b : 'b'}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', \"chartRender\":{}, b : 'b'}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{\"chartRender\":{render:function() {}}, a: 'a', b : 'b'}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{\"chartRender\":{}, a: 'a', b : 'b'}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + + // 带注释 + { + String text = "{a: 'a', b : 'b', /*sdf*/chartRender/*sdf*/:{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', /*sdf*/chartRender/*sdf*/:{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{a: 'a', b : 'b', /*sdf*/ chartRender /*sdf*/ :{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', /*sdf*/ chartRender /*sdf*/ :{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{a: 'a', b : 'b', //sdf\nchartRender//sdf\n:{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', //sdf\nchartRender//sdf\n:{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + { + String text = "{a: 'a', b : 'b', //sdf\n chartRender //sdf\n :{render:function() {}}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', //sdf\n chartRender //sdf\n :{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() {}}", content.getPluginChartRender()); + } + + // 复杂内容 + + { + String text = "{a: 'a', b : 'b', //sdf\n chartRender //sdf\n :{render:function() { if(a==b) {}; /*sdf*/ \n\n //sdf\n var a= {}; }}}"; + + JsDefContent content = resolver.resolve(text); + + Assert.assertEquals("{a: 'a', b : 'b', //sdf\n chartRender //sdf\n :{}}", content.getPluginJson()); + Assert.assertEquals("{render:function() { if(a==b) {}; /*sdf*/ \n\n //sdf\n var a= {}; }}", + content.getPluginChartRender()); + } + } +} diff --git a/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginTest.java b/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginTest.java index a250f673..2d940b56 100644 --- a/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginTest.java +++ b/datagear-analysis/src/test/java/org/datagear/analysis/support/html/HtmlChartPluginTest.java @@ -7,15 +7,12 @@ */ package org.datagear.analysis.support.html; -import java.io.InputStream; +import java.io.File; import java.io.StringWriter; import java.util.Locale; -import java.util.Map; import org.datagear.analysis.ChartDataSet; import org.datagear.analysis.RenderStyle; -import org.datagear.analysis.support.JsonChartPluginPropertiesResolver; -import org.datagear.analysis.support.LocationResource; import org.datagear.analysis.support.SimpleDashboardThemeSource; import org.datagear.analysis.support.html.HtmlRenderContext.WebContext; import org.junit.Assert; @@ -27,8 +24,6 @@ import org.junit.Test; */ public class HtmlChartPluginTest { - private static JsonChartPluginPropertiesResolver jsonChartPluginPropertiesResolver = new JsonChartPluginPropertiesResolver(); - public HtmlChartPluginTest() throws Throwable { super(); @@ -74,16 +69,11 @@ public class HtmlChartPluginTest public static HtmlChartPlugin createHtmlChartPlugin() throws Exception { - InputStream jsonInputStream = HtmlChartPluginTest.class.getClassLoader() - .getResourceAsStream("org/datagear/analysis/support/html/HtmlChartPlugin.config.json"); - Map properties = jsonChartPluginPropertiesResolver.resolveChartPluginProperties(jsonInputStream, - "UTF-8"); + File directory = new File("src/test/resources/org/datagear/analysis/support/html/HtmlChartPluginTest"); - HtmlChartPlugin htmlChartPlugin = new HtmlChartPlugin(); - jsonChartPluginPropertiesResolver.setChartPluginProperties(htmlChartPlugin, properties); - - htmlChartPlugin.setJsChartRenderer(new LocationJsChartRenderer( - LocationResource.toClasspathLocation("org/datagear/analysis/support/html/HtmlChartPlugin.chart.js"))); + @SuppressWarnings("unchecked") + HtmlChartPlugin htmlChartPlugin = (HtmlChartPlugin) new HtmlChartPluginLoader() + .load(directory); return htmlChartPlugin; } diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.chart.js b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.chart.js deleted file mode 100644 index 3e1b2128..00000000 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.chart.js +++ /dev/null @@ -1,24 +0,0 @@ -{ - render: function(chart) - { - var element = document.getElementById(chart.elementId); - var innerHtml = "my chart"; - - if(chart.renderContext && chart.renderContext.attributes && chart.renderContext.attributes.chartTheme) - { - var graphColors = (chart.renderContext.attributes.chartTheme.graphColors || []); - - for(var i=0; i< graphColors.length; i++) - { - innerHtml +="
 
"; - } - } - - element.innerHTML = innerHtml; - }, - update: function(chart, results) - { - var element = document.getElementById(chart.elementId); - element.innerHTML += "
update
"; - } -} diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.config.json b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.config.json deleted file mode 100644 index 2b78f808..00000000 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/HtmlChartPlugin.config.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - id : 'pie-chart', - nameLabel : - { - value : '饼图', - localeValues : - { - 'en' : 'pie chart', - 'zh' : '饼图中文' - } - } -} \ No newline at end of file diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/chart.js b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/chart.js deleted file mode 100644 index 5dae7ec6..00000000 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/chart.js +++ /dev/null @@ -1,6 +0,0 @@ -(function(chart) -{ - chart.render = function(){}; - chart.update = function(dataSets){}; -}) -($CHART); diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/properties.json b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/plugin.js similarity index 82% rename from datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/properties.json rename to datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/plugin.js index eaea04c4..2f5e2ac5 100644 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/properties.json +++ b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin01/plugin.js @@ -10,5 +10,6 @@ } }, icons : { "light" : "icon-01.png", "dark" : "icons/icon-02.png" }, - order : 4 + order : 4, + chartRender : {} } \ No newline at end of file diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/chart.js b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/chart.js deleted file mode 100644 index 5dae7ec6..00000000 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/chart.js +++ /dev/null @@ -1,6 +0,0 @@ -(function(chart) -{ - chart.render = function(){}; - chart.update = function(dataSets){}; -}) -($CHART); diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/properties.json b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/plugin.js similarity index 82% rename from datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/properties.json rename to datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/plugin.js index d9d2cb31..c559a5d3 100644 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/properties.json +++ b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin02/plugin.js @@ -10,5 +10,6 @@ } }, icons : { "light" : "icon-01.png", "dark" : "icons/icon-02.png" }, - order : 3 + order : 3, + chartRender : {} } \ No newline at end of file diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin03.zip b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginLoaders/plugin03.zip index 9969fd228bf63288d1b195015563551cf36a555b..58a4cada2647e4f7f59de0c23d5bc57d48abae3c 100644 GIT binary patch delta 350 zcmX@j{)u&B?Ueec73KkVFZWE_!N9=q6Nov1xFDxAJu^=)tJt;ImhX@OPwR7q!gdXB zu{y7tRcvZ(-!4Sux_GSKlDgnk&k;req4WfIo&rgY>j(T)BXoY(&Yw5?VZ+N7_ZYEd zep`8;6}3zZjgDAhDk1mKRp_>6FmvbKkAHUB-=E%YKJ#R9SZadnmM>-NjXA?6tC?dEOyXdOd!dy&mXk$gpqrObj-Bq!gI<`Sj^b ze`o)l`X^(V_*y6M{jcW~Q(kk_{jK=qk4!R?BbfLY878MQ#V{I7KEf2v7&2Lg*(DXz z!zw^8gMb1McL6cn`&?il1_nk32?piN%B;5+uQKWsEQ|xuPSMZ2Ky-jND;rP`0}Buq MGcqt_0x<&v08T-H?*IS* delta 577 zcmeywdYZjHz?+#xgn@y9gW-DZWdF#thxy?^UKUt{fgw2~v8Y5ZtJt?^BUgihi0gBf z{|6U3POnptTC{ZMFUE`FTO;<&oBZRwE!UB^a_1htvSo9BF1p29XVOF^&xB=BqS`wkJ8d_UZT+;LKHD$b=*>>7VGQt|$TX=wqG7WCObx&CbwEp>0Wm)i z7Zl|eq!yKArWONj&(Cu`W60NJAj0-wr^=m$FE6o*7Cz=V_fAwQV@<0_!GsdCj||6- z81Il~-`n%Zv}V1^u04Cc|BsK8XLEUKvUJb2*o8iO9tgU)*7x1DC;!*SZGT;0RgfdY)9#i! zHM8N%l+4g6y3KPFEjpiHz9piwNJqTv^Xb_)Z>a5C`p+}9IFnH&@xi_TZ$>7223*0a z0`wmUD1b=@O?W7CL4_C@Bp6s#H>p!K!rp2M5Y zn*CErnra*od1L*_2|DX$Z}8ONS;@+;(3HMGoO^H2v22UYjJa(yzt`@`Y-3&~ELRvg z!|JNpjMIW{VY!J5uO(Eph~Jh7rsAeH~Ig(>u+z(<(uTuy;#-#_)gux%pC?+XSEu4FDQ^{nS5wj(h=81cb-k3 zetF(Go2UC!$~i4WoUH!*SB>b|ASS;xezGl-79+#t45k=HgULsk!Wly*%QCy9VtQ5u z=v@#{0OBqnhI^e0EX2UT$RNRxmcFay?ZvB%PnZ*`L9|o!GcOPw;LXYg)Wg66gvE>u K44FX8zyJU+jD;ou delta 578 zcmeywdWO9|z?+#xgn@y9gW-DZWdF#thxy?^UKUt{fgw2~v8Y5ZtJt?^BUgihi0gBf z{|6U3POnptTC{ZMFUE`FTO;<&oBZRwE!UB^a_1htvSo9BF1p29XVOF^&xB=BqS`wkJ8d_UZT+;LKHD$b=*>>7VGQt|$TX=wqhYfDYKt1v^*~FX0Wm)i z7Zl|eq!yKArWONj&(Cu`W60NJAj0-wr^=m$FE6o*_6VmJl&!zukgU6;p?S&XPId#e zc?a)Wyhs&U|FBy1;?t*l|NsB=%RoVEx#rWY@3>MQvGyw%C23Dj(lzyc=;Tu7R4(+e zz^4A)`R`BbAF5sqRofDic)P;3=+M%KC$<_*N?W=?w<7+H_rL$2cg40}ZcKihU}2)Q z+J||`a-Y?UawOmI9QK^!lO4RFV^hqHv-zxr#<_U2aLWd6#mB(t$x=)T{M-!4`fDdoVT@s1JNYAH zIOE01o=h&;n8Asxo}CdRaFK20zn^r(323W+{Eh=4y29?vdJrAp&B_LHEh`XS1{(1g Hh#43FjkC)1 diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginTest/plugin.js b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginTest/plugin.js new file mode 100644 index 00000000..bc16df6e --- /dev/null +++ b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlChartPluginTest/plugin.js @@ -0,0 +1,37 @@ +{ + id : 'pie-chart', + nameLabel : + { + value : '饼图', + localeValues : + { + 'en' : 'pie chart', + 'zh' : '饼图中文' + } + }, + chartRender: + { + render: function(chart) + { + var element = document.getElementById(chart.elementId); + var innerHtml = "my chart"; + + if(chart.renderContext && chart.renderContext.attributes && chart.renderContext.attributes.chartTheme) + { + var graphColors = (chart.renderContext.attributes.chartTheme.graphColors || []); + + for(var i=0; i< graphColors.length; i++) + { + innerHtml +="
 
"; + } + } + + element.innerHTML = innerHtml; + }, + update: function(chart, results) + { + var element = document.getElementById(chart.elementId); + element.innerHTML += "
update
"; + } + } +} diff --git a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/html/widget01/index.html b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/html/widget01/index.html index 17ea6039..82f382a0 100644 --- a/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/html/widget01/index.html +++ b/datagear-analysis/src/test/resources/org/datagear/analysis/support/html/htmlTplDashboardWidgets/html/widget01/index.html @@ -10,7 +10,7 @@ var dashboardRenderer = for(var i=0; i localeValues; diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/chart.js b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/chart.js deleted file mode 100644 index 4bd35c27..00000000 --- a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/chart.js +++ /dev/null @@ -1,43 +0,0 @@ -{ -/** - * 依赖: - * chartUtil - * echarts - */ - render: function(chart) - { - chart.echarts = {}; - - var options = - { - xAxis: { - type: 'category', - boundaryGap: false, - data: [] - }, - yAxis: { - type: 'value' - }, - series: [{ - data: [], - type: 'bar' - }] - }; - - chart.echarts.chart = chartUtil.echarts.init(chart, options); - }, - update: function(chart, results) - { - var chartDataSet = chartUtil.firstChartDataSet(chart); - var result = chartUtil.firstResult(results); - - var xp = chartUtil.dataSetPropertyOfSign(chartDataSet, "x-value"); - var yp = chartUtil.dataSetPropertyOfSign(chartDataSet, "y-value"); - - var xdatas = chartUtil.dataPropertyValues(result, xp); - var ydatas = chartUtil.dataPropertyValues(result, yp); - - var options = { xAxis : { data : xdatas }, series : [ { data : ydatas } ] }; - chart.echarts.chart.setOption(options); - } -} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/plugin.js b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/plugin.js new file mode 100644 index 00000000..95e55912 --- /dev/null +++ b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/plugin.js @@ -0,0 +1,56 @@ +{ + id : 'datagear-chart-bar', + nameLabel : '柱状图', + descLabel : '柱状图', + dataSigns : + [ + { name : "x-value", nameLabel : "横坐标", occurRequired: true, occurMultiple: false }, + { name : "y-value", nameLabel : "纵坐标", occurRequired: true, occurMultiple: true } + ], + version: "0.1.0", + order : 1, + chartRender: + { + /** + * 依赖: + * chartUtil + * echarts + */ + render: function(chart) + { + chart.echarts = {}; + + var options = + { + xAxis: { + type: 'category', + boundaryGap: false, + data: [] + }, + yAxis: { + type: 'value' + }, + series: [{ + data: [], + type: 'bar' + }] + }; + + chart.echarts.chart = chartUtil.echarts.init(chart, options); + }, + update: function(chart, results) + { + var chartDataSet = chartUtil.firstChartDataSet(chart); + var result = chartUtil.firstResult(results); + + var xp = chartUtil.dataSetPropertyOfSign(chartDataSet, "x-value"); + var yp = chartUtil.dataSetPropertyOfSign(chartDataSet, "y-value"); + + var xdatas = chartUtil.dataPropertyValues(result, xp); + var ydatas = chartUtil.dataPropertyValues(result, yp); + + var options = { xAxis : { data : xdatas }, series : [ { data : ydatas } ] }; + chart.echarts.chart.setOption(options); + } + } +} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/properties.json b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/properties.json deleted file mode 100644 index c54cdd3d..00000000 --- a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-bar-0.1.0/properties.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - id : 'datagear-chart-bar', - nameLabel : '柱状图', - descLabel : '柱状图', - dataSigns : - [ - { name : "x-value", nameLabel : "横坐标", occurRequired: true, occurMultiple: false }, - { name : "y-value", nameLabel : "纵坐标", occurRequired: true, occurMultiple: true } - ], - version: "0.1.0", - order : 1 -} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/chart.js b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/chart.js deleted file mode 100644 index 359b3247..00000000 --- a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/chart.js +++ /dev/null @@ -1,43 +0,0 @@ -{ -/** - * 依赖: - * chartUtil - * echarts - */ - render: function(chart) - { - chart.echarts = {}; - - var options = - { - xAxis: { - type: 'category', - boundaryGap: false, - data: [] - }, - yAxis: { - type: 'value', - }, - series: [{ - data: [], - type: 'line' - }] - }; - - chart.echarts.chart = chartUtil.echarts.init(chart, options); - }, - update: function(chart, results) - { - var chartDataSet = chartUtil.firstChartDataSet(chart); - var result = chartUtil.firstResult(results); - - var xp = chartUtil.dataSetPropertyOfSign(chartDataSet, "x-value"); - var yp = chartUtil.dataSetPropertyOfSign(chartDataSet, "y-value"); - - var xdatas = chartUtil.dataPropertyValues(result, xp); - var ydatas = chartUtil.dataPropertyValues(result, yp); - - var options = { xAxis : { data : xdatas }, series : [ { data : ydatas } ] }; - chart.echarts.chart.setOption(options); - } -} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/plugin.js b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/plugin.js new file mode 100644 index 00000000..42a54567 --- /dev/null +++ b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/plugin.js @@ -0,0 +1,56 @@ +{ + id : 'datagear-chart-line', + nameLabel : '折线图', + descLabel : '折线图', + dataSigns : + [ + { name : "x-value", nameLabel : "横坐标", occurRequired: true, occurMultiple: false }, + { name : "y-value", nameLabel : "纵坐标", occurRequired: true, occurMultiple: true } + ], + version: "0.1.0", + order : 0, + chartRender: + { + /** + * 依赖: + * chartUtil + * echarts + */ + render: function(chart) + { + chart.echarts = {}; + + var options = + { + xAxis: { + type: 'category', + boundaryGap: false, + data: [] + }, + yAxis: { + type: 'value', + }, + series: [{ + data: [], + type: 'line' + }] + }; + + chart.echarts.chart = chartUtil.echarts.init(chart, options); + }, + update: function(chart, results) + { + var chartDataSet = chartUtil.firstChartDataSet(chart); + var result = chartUtil.firstResult(results); + + var xp = chartUtil.dataSetPropertyOfSign(chartDataSet, "x-value"); + var yp = chartUtil.dataSetPropertyOfSign(chartDataSet, "y-value"); + + var xdatas = chartUtil.dataPropertyValues(result, xp); + var ydatas = chartUtil.dataPropertyValues(result, yp); + + var options = { xAxis : { data : xdatas }, series : [ { data : ydatas } ] }; + chart.echarts.chart.setOption(options); + } + } +} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/properties.json b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/properties.json deleted file mode 100644 index 6b9632e6..00000000 --- a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-line-0.1.0/properties.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - id : 'datagear-chart-line', - nameLabel : '折线图', - descLabel : '折线图', - dataSigns : - [ - { name : "x-value", nameLabel : "横坐标", occurRequired: true, occurMultiple: false }, - { name : "y-value", nameLabel : "纵坐标", occurRequired: true, occurMultiple: true } - ], - version: "0.1.0", - order : 0 -} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/chart.js b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/chart.js deleted file mode 100644 index 127a77cc..00000000 --- a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/chart.js +++ /dev/null @@ -1,60 +0,0 @@ -{ -/** - * 依赖: - * chartUtil - * echarts - */ - render: function(chart) - { - chart.echarts = {}; - - var options = - { - tooltip: - { - trigger: 'item', - formatter: '{a}
{b} : {c} ({d}%)' - }, - legend: - { - orient: 'vertical', - left: 'left' - }, - series: - [ - { - name : "", - type: 'pie', - radius: '55%', - center: ['50%', '60%'], - data: [], - emphasis: - { - itemStyle: - { - shadowBlur: 10, - shadowOffsetX: 0, - shadowColor: chartUtil.chartTheme(chart).envLeastColor - } - } - } - ] - }; - - chart.echarts.chart = chartUtil.echarts.init(chart, options); - }, - update: function(chart, results) - { - var chartDataSet = chartUtil.firstChartDataSet(chart); - var result = chartUtil.firstResult(results); - - var np = chartUtil.dataSetPropertyOfSign(chartDataSet, "name"); - var vp = chartUtil.dataSetPropertyOfSign(chartDataSet, "value"); - - var legendData = chartUtil.dataPropertyValues(result, np); - var datas = chartUtil.dataNameValueObjects(result, np, vp); - - var options = { legend : { data : legendData }, series : [ { name : chartUtil.propertyValueName(chart), data : datas } ] }; - chart.echarts.chart.setOption(options); - } -} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/plugin.js b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/plugin.js new file mode 100644 index 00000000..cefab989 --- /dev/null +++ b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/plugin.js @@ -0,0 +1,73 @@ +{ + id : 'datagear-chart-pie', + nameLabel : '饼图', + descLabel : '饼图', + dataSigns : + [ + { name : "name", nameLabel : "名称", occurRequired: true, occurMultiple: false }, + { name : "value", nameLabel : "数值", occurRequired: true, occurMultiple: true } + ], + version: "0.1.0", + order : 2, + chartRender: + { + /** + * 依赖: + * chartUtil + * echarts + */ + render: function(chart) + { + chart.echarts = {}; + + var options = + { + tooltip: + { + trigger: 'item', + formatter: '{a}
{b} : {c} ({d}%)' + }, + legend: + { + orient: 'vertical', + left: 'left' + }, + series: + [ + { + name : "", + type: 'pie', + radius: '55%', + center: ['50%', '60%'], + data: [], + emphasis: + { + itemStyle: + { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: chartUtil.chartTheme(chart).envLeastColor + } + } + } + ] + }; + + chart.echarts.chart = chartUtil.echarts.init(chart, options); + }, + update: function(chart, results) + { + var chartDataSet = chartUtil.firstChartDataSet(chart); + var result = chartUtil.firstResult(results); + + var np = chartUtil.dataSetPropertyOfSign(chartDataSet, "name"); + var vp = chartUtil.dataSetPropertyOfSign(chartDataSet, "value"); + + var legendData = chartUtil.dataPropertyValues(result, np); + var datas = chartUtil.dataNameValueObjects(result, np, vp); + + var options = { legend : { data : legendData }, series : [ { name : chartUtil.propertyValueName(chart), data : datas } ] }; + chart.echarts.chart.setOption(options); + } + } +} \ No newline at end of file diff --git a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/properties.json b/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/properties.json deleted file mode 100644 index 0cefdfe8..00000000 --- a/datagear-web/src/main/resources/org/datagear/web/chartPlugin/datagear-chart-pie-0.1.0/properties.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - id : 'datagear-chart-pie', - nameLabel : '饼图', - descLabel : '饼图', - dataSigns : - [ - { name : "name", nameLabel : "名称", occurRequired: true, occurMultiple: false }, - { name : "value", nameLabel : "数值", occurRequired: true, occurMultiple: true } - ], - version: "0.1.0", - order : 2 -} \ No newline at end of file diff --git a/datagear-web/src/main/webapp/static/script/datagear-dashboard-renderer.js b/datagear-web/src/main/webapp/static/script/datagear-dashboard-renderer.js index 1d8b2b32..c3fcba13 100644 --- a/datagear-web/src/main/webapp/static/script/datagear-dashboard-renderer.js +++ b/datagear-web/src/main/webapp/static/script/datagear-dashboard-renderer.js @@ -33,7 +33,7 @@ try { - chart.plugin.jsChartRender.render(chart); + chart.plugin.chartRender.render(chart); } catch(e) { @@ -180,7 +180,7 @@ doUpdate=this.listener.onUpdateChart(dashboard, chart, results, this); if(doUpdate != false) - chart.plugin.jsChartRender.update(chart, results); + chart.plugin.chartRender.update(chart, results); }; renderer.handleError = function(e)