From 9da097c5934b885fdd33a0433a19ba864329627e Mon Sep 17 00:00:00 2001 From: jiawulin001 Date: Mon, 28 Mar 2022 15:03:32 +0800 Subject: [PATCH 1/2] fix: issue#16749 colorAlpha check --- src/chart/treemap/treemapVisual.ts | 2 +- src/model/Model.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chart/treemap/treemapVisual.ts b/src/chart/treemap/treemapVisual.ts index 3554ceb86f..d830253c00 100644 --- a/src/chart/treemap/treemapVisual.ts +++ b/src/chart/treemap/treemapVisual.ts @@ -137,7 +137,7 @@ function buildVisuals( return visuals; } -function calculateColor(visuals: TreemapVisual) { +export function calculateColor(visuals: TreemapVisual) { let color = getValueVisualDefine(visuals, 'color') as ColorString; if (color) { diff --git a/src/model/Model.ts b/src/model/Model.ts index 3ebffaf4ec..a37c4150b5 100644 --- a/src/model/Model.ts +++ b/src/model/Model.ts @@ -33,6 +33,7 @@ import GlobalModel from './Global'; import { AnimationOptionMixin, ModelOption } from '../util/types'; import { Dictionary } from 'zrender/src/core/types'; import { mixin, clone, merge } from 'zrender/src/core/util'; +import { calculateColor } from '../chart/treemap/treemapVisual'; // Since model.option can be not only `Dictionary` but also primary types, // we do this conditional type to avoid getting type 'never'; @@ -123,6 +124,9 @@ class Model { // TODO: TYPE use unknown instead of any? const option = this.option; let val = option == null ? option : option[key]; + if (val && key === 'color' && ('colorAlpha' in option)){ + val = ((calculateColor(option)) as unknown) as Opt[R]; + } if (val == null && !ignoreParent) { const parentModel = this.parentModel; if (parentModel) { From ef5edb804b3bafb9177bf292c1a4ca53a8b6d629 Mon Sep 17 00:00:00 2001 From: jiawulin001 Date: Mon, 28 Mar 2022 15:24:14 +0800 Subject: [PATCH 2/2] colorAlpha testcase added --- test/treemap-itemStyle-colorAlpha.html | 121 +++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 test/treemap-itemStyle-colorAlpha.html diff --git a/test/treemap-itemStyle-colorAlpha.html b/test/treemap-itemStyle-colorAlpha.html new file mode 100644 index 0000000000..582ed7e2df --- /dev/null +++ b/test/treemap-itemStyle-colorAlpha.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +