You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2018/06/13 19:21:08 UTC

[incubator-echarts] 01/02: tweak custom series style setting.

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

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

commit e509060ca13dfd1332a6f94c38d3944957ef321d
Author: sushuang <su...@gmail.com>
AuthorDate: Thu Jun 14 03:20:10 2018 +0800

    tweak custom series style setting.
---
 src/chart/custom.js | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/chart/custom.js b/src/chart/custom.js
index 191cc9b..148f529 100644
--- a/src/chart/custom.js
+++ b/src/chart/custom.js
@@ -218,7 +218,7 @@ function createEl(elOption) {
     return el;
 }
 
-function updateEl(el, dataIndex, elOption, animatableModel, data, isInit) {
+function updateEl(el, dataIndex, elOption, animatableModel, data, isInit, isRoot) {
     var targetProps = {};
     var elOptionStyle = elOption.style || {};
 
@@ -272,7 +272,21 @@ function updateEl(el, dataIndex, elOption, animatableModel, data, isInit) {
     // z2 must not be null/undefined, otherwise sort error may occur.
     el.attr({z2: elOption.z2 || 0, silent: elOption.silent});
 
-    elOption.styleEmphasis !== false && graphicUtil.setHoverStyle(el, elOption.styleEmphasis);
+    // If `elOption.styleEmphasis` is `false`, remove hover style. The
+    // logic is ensured by `graphicUtil.setElementHoverStyle`.
+    var styleEmphasis = elOption.styleEmphasis;
+    var disableStyleEmphasis = styleEmphasis === false;
+    if (!(
+        // Try to escapse setting hover style for performance.
+        (el.__cusHasEmphStl && styleEmphasis == null)
+        || (!el.__cusHasEmphStl && disableStyleEmphasis)
+    )) {
+        // Should not use graphicUtil.setHoverStyle, since the styleEmphasis
+        // should not be share by group and its descendants.
+        graphicUtil.setElementHoverStyle(el, styleEmphasis);
+        el.__cusHasEmphStl = !disableStyleEmphasis;
+    }
+    isRoot && graphicUtil.setAsHoverStyleTrigger(el, !disableStyleEmphasis);
 }
 
 function prepareStyleTransition(prop, targetStyle, elOptionStyle, oldElStyle, isInit) {
@@ -496,13 +510,13 @@ function wrapEncodeDef(data) {
 }
 
 function createOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
-    el = doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data);
+    el = doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data, true);
     el && data.setItemGraphicEl(dataIndex, el);
 
     return el;
 }
 
-function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data) {
+function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data, isRoot) {
     elOption = elOption || {};
 
     var elOptionType = elOption.type;
@@ -528,7 +542,7 @@ function doCreateOrUpdate(el, dataIndex, elOption, animatableModel, group, data)
 
     var isInit = !el;
     !el && (el = createEl(elOption));
-    updateEl(el, dataIndex, elOption, animatableModel, data, isInit);
+    updateEl(el, dataIndex, elOption, animatableModel, data, isInit, isRoot);
 
     // If `renderItem` returns no children, follow the principle of
     // "merge", remain the children of the original elements

-- 
To stop receiving notification emails like this one, please contact
sushuang@apache.org.

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