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) { 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 @@ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +