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


The following commit(s) were added to refs/heads/merge-release-to-next by this 
push:
     new ce9f1e5  fix: rollback 565535fc9906a78e701819f62de42a0ffb0f674a. That 
will be compat in preprocessor.
ce9f1e5 is described below

commit ce9f1e596747fdde5603389592c32af45a25cb6b
Author: 100pah <sushuang0...@gmail.com>
AuthorDate: Wed May 27 15:08:02 2020 +0800

    fix: rollback 565535fc9906a78e701819f62de42a0ffb0f674a. That will be compat 
in preprocessor.
---
 src/chart/bar/BarSeries.ts    |   6 +--
 src/chart/bar/BarView.ts      |  24 ++++-----
 src/chart/bar/barItemStyle.ts | 117 ------------------------------------------
 3 files changed, 12 insertions(+), 135 deletions(-)

diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts
index 206ad57..dad4736 100644
--- a/src/chart/bar/BarSeries.ts
+++ b/src/chart/bar/BarSeries.ts
@@ -19,7 +19,7 @@
 
 import BaseBarSeriesModel, {BaseBarSeriesOption} from './BaseBarSeries';
 import SeriesModel from '../../model/Series';
-import { ItemStyleOption, OptionDataValue, LabelOption, 
SeriesStackOptionMixin, ZRColor } from '../../util/types';
+import { ItemStyleOption, OptionDataValue, LabelOption, SeriesStackOptionMixin 
} from '../../util/types';
 import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
 import type Polar from '../../coord/polar/Polar';
 import { inheritDefaultOption } from '../../util/component';
@@ -31,10 +31,6 @@ type BarDataValue = OptionDataValue | OptionDataValue[];
 export interface BarItemStyleOption extends ItemStyleOption {
     // Border radius is not supported for bar on polar
     borderRadius?: number | number[]
-    // Compat. See `src/chart/bar/barItemStyle`.
-    barBorderRadius?: number | number[]
-    barBorderColor?: ItemStyleOption['borderColor']
-    barBorderWidth?: ItemStyleOption['borderWidth']
 }
 export interface BarDataItemOption {
     name?: string
diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index 2a5710e..299a46f 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -46,11 +46,9 @@ import type { RectLike } from 
'zrender/src/core/BoundingRect';
 import type Model from '../../model/Model';
 import { isCoordinateSystemType } from '../../coord/CoordinateSystem';
 import { getDefaultLabel } from '../helper/labelHelper';
-import {
-    getBarItemStyle, fixBarItemStyle, getBarItemModelBorderWidth,
-    getBarBorderColor, getBarBorderRadius, getBarItemModelBorderRadius
-} from './barItemStyle';
 
+const BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'borderWidth'] as const;
+const BAR_BORDER_RADIUS_QUERY = ['itemStyle', 'borderRadius'] as const;
 const _eventPos = [0, 0];
 
 const mathMax = Math.max;
@@ -169,7 +167,7 @@ class BarView extends ChartView {
 
         const drawBackground = seriesModel.get('showBackground', true);
         const backgroundModel = seriesModel.getModel('backgroundStyle');
-        const barBorderRadius = getBarBorderRadius(backgroundModel) || 0;
+        const barBorderRadius = backgroundModel.get('borderRadius') || 0;
 
         const bgEls: BarView['_backgroundEls'] = [];
         const oldBgEls = this._backgroundEls;
@@ -182,7 +180,7 @@ class BarView extends ChartView {
                 if (drawBackground) {
                     const bgLayout = getLayout[coord.type](data, dataIndex);
                     const bgEl = createBackgroundEl(coord, 
isHorizontalOrRadial, bgLayout);
-                    bgEl.useStyle(getBarItemStyle(backgroundModel));
+                    bgEl.useStyle(backgroundModel.getItemStyle());
                     // Only cartesian2d support borderRadius.
                     if (coord.type === 'cartesian2d') {
                         (bgEl as Rect).setShape('r', barBorderRadius);
@@ -222,7 +220,7 @@ class BarView extends ChartView {
 
                 if (drawBackground) {
                     const bgEl = oldBgEls[oldIndex];
-                    bgEl.useStyle(getBarItemStyle(backgroundModel));
+                    bgEl.useStyle(backgroundModel.getItemStyle());
                     // Only cartesian2d support borderRadius.
                     if (coord.type === 'cartesian2d') {
                         (bgEl as Rect).setShape('r', barBorderRadius);
@@ -556,13 +554,13 @@ function updateStyle(
     isPolar: boolean
 ) {
     const style = data.getItemVisual(dataIndex, 'style');
-    const hoverStyle = getBarItemStyle(itemModel.getModel(['emphasis', 
'itemStyle']));
+    const hoverStyle = itemModel.getModel(['emphasis', 
'itemStyle']).getItemStyle();
 
     if (!isPolar) {
-        (el as Rect).setShape('r', getBarItemModelBorderRadius(itemModel) || 
0);
+        (el as Rect).setShape('r', itemModel.get(BAR_BORDER_RADIUS_QUERY) || 
0);
     }
 
-    el.useStyle(fixBarItemStyle(itemModel, style));
+    el.useStyle(style);
 
     el.ignore = isZeroOnPolar(layout as SectorLayout);
 
@@ -598,7 +596,7 @@ function getLineWidth(
     itemModel: Model<BarSeriesOption>,
     rawLayout: RectLayout
 ) {
-    const lineWidth = getBarItemModelBorderWidth(itemModel) || 0;
+    const lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
     // width or height may be NaN for empty data
     const width = isNaN(rawLayout.width) ? Number.MAX_VALUE : 
Math.abs(rawLayout.width);
     const height = isNaN(rawLayout.height) ? Number.MAX_VALUE : 
Math.abs(rawLayout.height);
@@ -760,8 +758,8 @@ function setLargeBackgroundStyle(
     backgroundModel: Model<BarSeriesOption['backgroundStyle']>,
     data: List
 ) {
-    const borderColor = getBarBorderColor(backgroundModel) || 
backgroundModel.get('color');
-    const itemStyle = getBarItemStyle(backgroundModel);
+    const borderColor = backgroundModel.get('borderColor') || 
backgroundModel.get('color');
+    const itemStyle = backgroundModel.getItemStyle();
 
     el.useStyle(itemStyle);
     el.style.fill = null;
diff --git a/src/chart/bar/barItemStyle.ts b/src/chart/bar/barItemStyle.ts
deleted file mode 100644
index b6ac517..0000000
--- a/src/chart/bar/barItemStyle.ts
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*   http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied.  See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-import makeStyleMapper from '../../model/mixin/makeStyleMapper';
-import * as zrUtil from 'zrender/src/core/util';
-import Model from '../../model/Model';
-import { ItemStyleOption, Dictionary } from '../../util/types';
-import { PathStyleProps } from 'zrender/src/graphic/Path';
-import { BarDataItemOption, BarItemStyleOption } from './BarSeries';
-
-const ITEM_STYLE_BAR_BORDER_COLOR = ['itemStyle', 'barBorderColor'] as const;
-const ITEM_STYLE_BAR_BORDER_WIDTH = ['itemStyle', 'barBorderWidth'] as const;
-const ITEM_STYLE_BORDER_WIDTH = ['itemStyle', 'borderWidth'] as const;
-const ITEM_STYLE_BAR_BORDER_RADIUS = ['itemStyle', 'barBorderRadius'] as const;
-const ITEM_STYLE_BORDER_RADIUS = ['itemStyle', 'borderRadius'] as const;
-
-const getBarItemStyleInner = makeStyleMapper(
-    [
-        ['fill', 'color'],
-        ['stroke', 'borderColor'],
-        ['lineWidth', 'borderWidth'],
-        // Previously echarts2 use 'barBorderXxx' to distinguish
-        // with `borderXxx` for "magic type" feature. That seams
-        // not a neat strategy. We should better unify the name
-        // of those props to `borderXxx` rather than `barBorderXxx`.
-        // 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'],
-        ['shadowBlur'],
-        ['shadowOffsetX'],
-        ['shadowOffsetY'],
-        ['shadowColor']
-    ]
-);
-
-export function getBarItemStyle(
-    model: Model,
-    excludes?: readonly (keyof ItemStyleOption)[]
-) {
-    const style = getBarItemStyleInner(model, excludes);
-    if (model.getBorderLineDash) {
-        const lineDash = model.getBorderLineDash();
-        lineDash && (style.lineDash = lineDash);
-    }
-    return style;
-}
-
-/**
- * If has `barBorderColor` or `barBorderWidth`, return a new style.
- * Otherwise return the input style.
- */
-export function fixBarItemStyle(
-    itemModel: Model<BarDataItemOption>,
-    style: PathStyleProps
-): PathStyleProps {
-
-    const barBorderColor = itemModel.get(ITEM_STYLE_BAR_BORDER_COLOR);
-    const barBorderWidth = itemModel.get(ITEM_STYLE_BAR_BORDER_WIDTH);
-
-    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;
-}
-
-export function getBarBorderColor(styleModel: Model<BarItemStyleOption>): 
BarItemStyleOption['borderColor'] {
-    return zrUtil.retrieve2(
-        styleModel.get('barBorderColor'),
-        styleModel.get('borderColor')
-    );
-}
-export function getBarBorderRadius(styleModel: Model<BarItemStyleOption>): 
BarItemStyleOption['borderRadius'] {
-    return zrUtil.retrieve2(
-        styleModel.get('barBorderRadius'),
-        styleModel.get('borderRadius')
-    );
-}
-
-export function getBarItemModelBorderWidth(itemModel: 
Model<BarDataItemOption>): BarItemStyleOption['borderWidth'] {
-    return zrUtil.retrieve2(
-        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_BAR_BORDER_RADIUS),
-        itemModel.get(ITEM_STYLE_BORDER_RADIUS)
-    );
-}
-


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

Reply via email to