diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts index d3482529dc..5b7729ada9 100644 --- a/src/chart/bar/BarView.ts +++ b/src/chart/bar/BarView.ts @@ -1061,4 +1061,4 @@ function createBackgroundEl( ChartView.registerClass(BarView); -export default BarView; \ No newline at end of file +export default BarView; diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts index 6062891f1a..dbc09c0350 100644 --- a/src/chart/helper/Line.ts +++ b/src/chart/helper/Line.ts @@ -460,4 +460,4 @@ class Line extends graphic.Group { } } -export default Line; \ No newline at end of file +export default Line; diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts index ba6e84e39f..0ddb15788f 100644 --- a/src/chart/helper/Symbol.ts +++ b/src/chart/helper/Symbol.ts @@ -200,7 +200,6 @@ class Symbol extends graphic.Group { const symbolPath = this.childAt(0) as ECSymbol; const seriesModel = data.hostModel as SeriesModel; - let emphasisItemStyle; let blurItemStyle; let selectItemStyle; @@ -232,8 +231,8 @@ class Symbol extends graphic.Group { if (!seriesScope || data.hasItemOption) { const itemModel = (seriesScope && seriesScope.itemModel) ? seriesScope.itemModel : data.getItemModel(idx); - const emphasisModel = itemModel.getModel('emphasis'); + emphasisItemStyle = emphasisModel.getModel('itemStyle').getItemStyle(); selectItemStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle(); blurItemStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle(); @@ -383,4 +382,4 @@ function driftSymbol(this: ECSymbol, dx: number, dy: number) { } -export default Symbol; \ No newline at end of file +export default Symbol; diff --git a/src/chart/helper/SymbolDraw.ts b/src/chart/helper/SymbolDraw.ts index 1fd78ae5ec..fd864e6021 100644 --- a/src/chart/helper/SymbolDraw.ts +++ b/src/chart/helper/SymbolDraw.ts @@ -290,4 +290,4 @@ class SymbolDraw { } -export default SymbolDraw; \ No newline at end of file +export default SymbolDraw; diff --git a/src/component/axis/SingleAxisView.ts b/src/component/axis/SingleAxisView.ts index 582fe2eb5e..6bfb8007d5 100644 --- a/src/component/axis/SingleAxisView.ts +++ b/src/component/axis/SingleAxisView.ts @@ -93,7 +93,6 @@ const axisElementBuilders: Record, ecModel: GlobalModel diff --git a/src/model/mixin/itemStyle.ts b/src/model/mixin/itemStyle.ts index c3c2ad2159..959ecc49ee 100644 --- a/src/model/mixin/itemStyle.ts +++ b/src/model/mixin/itemStyle.ts @@ -30,7 +30,12 @@ export const ITEM_STYLE_KEY_MAP = [ ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], - ['shadowColor'] + ['shadowColor'], + ['lineDash', 'borderType'], + ['lineDashOffset', 'borderDashOffset'], + ['lineCap', 'borderCap'], + ['lineJoin', 'borderJoin'], + ['miterLimit', 'borderMiterLimit'] ]; const getItemStyle = makeStyleMapper(ITEM_STYLE_KEY_MAP); @@ -42,7 +47,12 @@ type ItemStyleKeys = 'fill' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' - | 'shadowColor'; + | 'shadowColor' + | 'lineDash' + | 'lineDashOffset' + | 'lineCap' + | 'lineJoin' + | 'miterLimit'; export type ItemStyleProps = Pick; @@ -53,17 +63,9 @@ class ItemStyleMixin { excludes?: readonly (keyof ItemStyleOption)[], includes?: readonly (keyof ItemStyleOption)[] ): ItemStyleProps { - const style = getItemStyle(this, excludes, includes); - const lineDash = this.getBorderLineDash(); - lineDash && (style.lineDash = lineDash); - return style; + return getItemStyle(this, excludes, includes); } - getBorderLineDash(this: Model): number[] { - const lineType = this.get('borderType'); - return (lineType === 'solid' || lineType == null) ? null - : (lineType === 'dashed' ? [5, 5] : [1, 1]); - } } export {ItemStyleMixin}; diff --git a/src/model/mixin/lineStyle.ts b/src/model/mixin/lineStyle.ts index 88512debda..9062308ff8 100644 --- a/src/model/mixin/lineStyle.ts +++ b/src/model/mixin/lineStyle.ts @@ -29,7 +29,12 @@ export const LINE_STYLE_KEY_MAP = [ ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], - ['shadowColor'] + ['shadowColor'], + ['lineDash', 'type'], + ['lineDashOffset', 'dashOffset'], + ['lineCap', 'cap'], + ['lineJoin', 'join'], + ['miterLimit'] ]; const getLineStyle = makeStyleMapper(LINE_STYLE_KEY_MAP); @@ -40,38 +45,24 @@ type LineStyleKeys = 'lineWidth' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' - | 'shadowColor'; + | 'shadowColor' + | 'lineDash' + | 'lineDashOffset' + | 'lineCap' + | 'lineJoin' + | 'miterLimit'; type LineStyleProps = Pick; class LineStyleMixin { - getLineStyle(this: Model, excludes?: readonly (keyof LineStyleOption)[]): LineStyleProps { - const style = getLineStyle(this, excludes); - // Always set lineDash whether dashed, otherwise we can not - // erase the previous style when assigning to el.style. - (style as any).lineDash = this.getLineDash((style as any).lineWidth); - return style; + getLineStyle( + this: Model, + excludes?: readonly (keyof LineStyleOption)[] + ): LineStyleProps { + return getLineStyle(this, excludes); } - getLineDash(this: Model, lineWidth?: number) { - if (lineWidth == null) { - lineWidth = 1; - } - const lineType = this.get('type'); - const dotSize = Math.max(lineWidth, 2); - const dashSize = lineWidth * 4; - 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]; - } }; export {LineStyleMixin}; diff --git a/src/util/types.ts b/src/util/types.ts index 52b490612c..1b3707e93f 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -64,7 +64,7 @@ export type VerticalAlign = 'top' | 'middle' | 'bottom'; // Types from zrender export type ColorString = string; export type ZRColor = ColorString | LinearGradientObject | RadialGradientObject | PatternObject; -export type ZRLineType = 'solid' | 'dotted' | 'dashed'; +export type ZRLineType = 'solid' | 'dotted' | 'dashed' | number | number[]; export type ZRFontStyle = 'normal' | 'italic' | 'oblique'; export type ZRFontWeight = 'normal' | 'bold' | 'bolder' | 'lighter' | number; @@ -655,6 +655,10 @@ export interface BorderOptionMixin { borderColor?: string borderWidth?: number borderType?: ZRLineType + borderCap?: CanvasLineCap + borderJoin?: CanvasLineJoin + borderDashOffset?: number + borderMiterLimit?: number } export type AnimationDelayCallbackParam = { @@ -777,6 +781,10 @@ export interface LineStyleOption extends ShadowOptionMixin { color?: Clr opacity?: number type?: ZRLineType + cap?: CanvasLineCap + join?: CanvasLineJoin + dashOffset?: number + miterLimit?: number } /** @@ -848,6 +856,8 @@ export interface TextCommonOption extends ShadowOptionMixin { } borderColor?: string borderWidth?: number + borderType?: ZRLineType + borderDashOffset?: number borderRadius?: number | number[] padding?: number | number[] @@ -855,6 +865,8 @@ export interface TextCommonOption extends ShadowOptionMixin { height?: number textBorderColor?: string textBorderWidth?: number + textBorderType?: ZRLineType + textBorderDashOffset?: number textShadowBlur?: number textShadowColor?: string diff --git a/src/visual/style.ts b/src/visual/style.ts index 1d52fcf605..2b3d006e15 100644 --- a/src/visual/style.ts +++ b/src/visual/style.ts @@ -213,4 +213,4 @@ export { seriesStyleTask, dataStyleTask, dataColorPaletteTask -}; \ No newline at end of file +}; diff --git a/test/line-style.html b/test/line-style.html index 92c6a574e2..875dacb683 100644 --- a/test/line-style.html +++ b/test/line-style.html @@ -31,10 +31,9 @@
-
+
+ +