From 7480736b5479e5b9db4dd45a921884f075387292 Mon Sep 17 00:00:00 2001 From: sushuang Date: Sun, 21 Apr 2019 12:45:33 +0800 Subject: [PATCH] Fix that setting `emphasis.lineStyle.type` as solid dose not work. Fix #9704, close #10129. --- src/model/mixin/lineStyle.js | 17 +++++++++--- test/hoverStyle.html | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/model/mixin/lineStyle.js b/src/model/mixin/lineStyle.js index 868e7d82c3..1889875554 100644 --- a/src/model/mixin/lineStyle.js +++ b/src/model/mixin/lineStyle.js @@ -34,8 +34,9 @@ var getLineStyle = makeStyleMapper( export default { getLineStyle: function (excludes) { var style = getLineStyle(this, excludes); - var lineDash = this.getLineDash(style.lineWidth); - lineDash && (style.lineDash = lineDash); + // Always set lineDash whether dashed, otherwise we can not + // erase the previous style when assigning to el.style. + style.lineDash = this.getLineDash(style.lineWidth); return style; }, @@ -46,7 +47,15 @@ export default { var lineType = this.get('type'); var dotSize = Math.max(lineWidth, 2); var dashSize = lineWidth * 4; - return (lineType === 'solid' || lineType == null) ? null - : (lineType === 'dashed' ? [dashSize, dashSize] : [dotSize, dotSize]); + return (lineType === 'solid' || lineType == null) + // Use `false` but not `null` for the solid line here, because `null` might be + // ignored when assigning to `el.style`. e.g., when setting `lineStyle.type` as + // `'dashed'` and `emphasis.lineStyle.type` as `'solid'` in graph series, the + // `lineDash` gotten form the latter one is not able to erase that from the former + // one if using `null` here according to the emhpsis strategy in `util/graphic.js`. + ? false + : lineType === 'dashed' + ? [dashSize, dashSize] + : [dotSize, dotSize]; } }; \ No newline at end of file diff --git a/test/hoverStyle.html b/test/hoverStyle.html index 993ed69bf5..e3f80dc22f 100644 --- a/test/hoverStyle.html +++ b/test/hoverStyle.html @@ -57,6 +57,7 @@
+
@@ -328,6 +329,56 @@ + + + + + +