From 72f4c419ae59e738740987b0d6affde96bca7f4b Mon Sep 17 00:00:00 2001 From: pissang Date: Fri, 7 Jan 2022 14:57:08 +0800 Subject: [PATCH] fix(visual): fix legend modify alpha on transparent color --- src/component/legend/LegendView.ts | 7 +- test/pie-case.html | 106 +++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 test/pie-case.html diff --git a/src/component/legend/LegendView.ts b/src/component/legend/LegendView.ts index 67e0145fcd..69df98221c 100644 --- a/src/component/legend/LegendView.ts +++ b/src/component/legend/LegendView.ts @@ -46,8 +46,7 @@ import { SymbolOptionMixin } from '../../util/types'; import Model from '../../model/Model'; -import {LineStyleProps, LINE_STYLE_KEY_MAP} from '../../model/mixin/lineStyle'; -import {ITEM_STYLE_KEY_MAP} from '../../model/mixin/itemStyle'; +import {LineStyleProps} from '../../model/mixin/lineStyle'; import {createSymbol, ECSymbol} from '../../util/symbol'; import SeriesModel from '../../model/Series'; @@ -244,7 +243,7 @@ class LegendView extends ComponentView { const idx = provider.indexOfName(name); - const style = provider.getItemVisual(idx, 'style') as PathStyleProps; + let style = provider.getItemVisual(idx, 'style') as PathStyleProps; const legendIcon = provider.getItemVisual(idx, 'legendIcon'); const colorArr = parse(style.fill as ColorString); @@ -253,7 +252,7 @@ class LegendView extends ComponentView { if (colorArr && colorArr[3] === 0) { colorArr[3] = 0.2; // TODO color is set to 0, 0, 0, 0. Should show correct RGBA - style.fill = stringify(colorArr, 'rgba'); + style = zrUtil.extend(zrUtil.extend({}, style), { fill: stringify(colorArr, 'rgba') }); } const itemGroup = this._createItem( diff --git a/test/pie-case.html b/test/pie-case.html new file mode 100644 index 0000000000..045178cc61 --- /dev/null +++ b/test/pie-case.html @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +