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 2020/05/26 20:45:11 UTC

[incubator-echarts] 05/05: fix: fix bar compat bug brought in 565535fc9906a78e701819f62de42a0ffb0f674a

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

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

commit e8c44b62afdddf5b6a7709bf587d376aaa60a494
Author: 100pah <su...@gmail.com>
AuthorDate: Wed May 27 04:44:03 2020 +0800

    fix: fix bar compat bug brought in 565535fc9906a78e701819f62de42a0ffb0f674a
---
 src/chart/bar/barItemStyle.ts | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/chart/bar/barItemStyle.ts b/src/chart/bar/barItemStyle.ts
index a76847a..b6ac517 100644
--- a/src/chart/bar/barItemStyle.ts
+++ b/src/chart/bar/barItemStyle.ts
@@ -42,6 +42,7 @@ const getBarItemStyleInner = makeStyleMapper(
         // But the echarts-doc has been describing it as `barBorderXxx`
         // until echarts4. So we still compat that settings to reduce
         // the break change.
+        // `barBorderXXX` always has higher priority.
         ['stroke', 'barBorderColor'],
         ['lineWidth', 'barBorderWidth'],
         ['opacity'],
@@ -75,18 +76,13 @@ export function fixBarItemStyle(
 
     const barBorderColor = itemModel.get(ITEM_STYLE_BAR_BORDER_COLOR);
     const barBorderWidth = itemModel.get(ITEM_STYLE_BAR_BORDER_WIDTH);
-    let newProps: Dictionary<unknown>;
 
-    if (barBorderColor != null) {
-        newProps = newProps || {};
-        newProps.barBorderColor = barBorderColor;
-    }
-    if (barBorderWidth != null) {
-        newProps = newProps || {};
-        newProps.barBorderColor = barBorderWidth;
-    }
-    if (newProps) {
-        style = zrUtil.createObject(style, newProps);
+    if (barBorderColor != null || barBorderWidth != null) {
+        // Here the `style` is a plain object, see `visual/style.ts`.
+        style = zrUtil.defaults({
+            stroke: barBorderColor,
+            lineWidth: barBorderWidth
+        }, style);
     }
 
     return style;
@@ -94,28 +90,28 @@ export function fixBarItemStyle(
 
 export function getBarBorderColor(styleModel: Model<BarItemStyleOption>): BarItemStyleOption['borderColor'] {
     return zrUtil.retrieve2(
-        styleModel.get('borderColor'),
-        styleModel.get('barBorderColor')
+        styleModel.get('barBorderColor'),
+        styleModel.get('borderColor')
     );
 }
 export function getBarBorderRadius(styleModel: Model<BarItemStyleOption>): BarItemStyleOption['borderRadius'] {
     return zrUtil.retrieve2(
-        styleModel.get('borderRadius'),
-        styleModel.get('barBorderRadius')
+        styleModel.get('barBorderRadius'),
+        styleModel.get('borderRadius')
     );
 }
 
 export function getBarItemModelBorderWidth(itemModel: Model<BarDataItemOption>): BarItemStyleOption['borderWidth'] {
     return zrUtil.retrieve2(
-        itemModel.get(ITEM_STYLE_BORDER_WIDTH),
-        itemModel.get(ITEM_STYLE_BAR_BORDER_WIDTH)
+        itemModel.get(ITEM_STYLE_BAR_BORDER_WIDTH),
+        itemModel.get(ITEM_STYLE_BORDER_WIDTH)
     );
 }
 
 export function getBarItemModelBorderRadius(itemModel: Model<BarDataItemOption>): BarItemStyleOption['borderRadius'] {
     return zrUtil.retrieve2(
-        itemModel.get(ITEM_STYLE_BORDER_RADIUS),
-        itemModel.get(ITEM_STYLE_BAR_BORDER_RADIUS)
+        itemModel.get(ITEM_STYLE_BAR_BORDER_RADIUS),
+        itemModel.get(ITEM_STYLE_BORDER_RADIUS)
     );
 }
 


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