You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2019/05/22 08:49:10 UTC

[incubator-echarts] branch master updated: 修复4.2.1之前版本都不可以使用symbol: Function的bug

This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 244d0b9  修复4.2.1之前版本都不可以使用symbol: Function的bug
244d0b9 is described below

commit 244d0b966e5768ced795c2977dd90530a3908279
Author: zhibi <10...@qq.com>
AuthorDate: Thu May 16 10:00:02 2019 +0800

    修复4.2.1之前版本都不可以使用symbol: Function的bug
---
 src/component/marker/MarkPointView.js | 6 +++++-
 src/util/symbol.js                    | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/component/marker/MarkPointView.js b/src/component/marker/MarkPointView.js
index ba6982a..d95b6f2 100644
--- a/src/component/marker/MarkPointView.js
+++ b/src/component/marker/MarkPointView.js
@@ -102,6 +102,10 @@ export default MarkerView.extend({
 
         mpData.each(function (idx) {
             var itemModel = mpData.getItemModel(idx);
+            var symbol = itemModel.getShallow('symbol');
+            if (typeof symbol === 'function') {
+                symbol = symbol(mpModel.getRawValue(idx), mpModel.getDataParams(idx));
+            }
             var symbolSize = itemModel.getShallow('symbolSize');
             if (typeof symbolSize === 'function') {
                 // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
@@ -113,7 +117,7 @@ export default MarkerView.extend({
                 symbolSize: symbolSize,
                 color: itemModel.get('itemStyle.color')
                     || seriesData.getVisual('color'),
-                symbol: itemModel.getShallow('symbol')
+                symbol: symbol
             });
         });
 
diff --git a/src/util/symbol.js b/src/util/symbol.js
index 0df28c2..54c4e7e 100644
--- a/src/util/symbol.js
+++ b/src/util/symbol.js
@@ -332,11 +332,15 @@ function symbolPathSetColor(color, innerColor) {
 export function createSymbol(symbolType, x, y, w, h, color, keepAspect) {
     // TODO Support image object, DynamicImage.
 
+    var isFunction = typeof symbolType === 'function'
+    if (isFunction) {
+        symbolType = symbolType();
+    }
+    var symbolPath;
     var isEmpty = symbolType.indexOf('empty') === 0;
     if (isEmpty) {
         symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
     }
-    var symbolPath;
 
     if (symbolType.indexOf('image://') === 0) {
         symbolPath = graphic.makeImage(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org