From 5d6fd8776adda2b59529d15dc74e15da53a6ebe1 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Tue, 27 Oct 2020 13:34:19 +0800 Subject: [PATCH] feat(decal): support "none" to disable decal --- src/util/decal.ts | 10 +++++++--- src/util/types.ts | 2 +- test/decal.html | 19 +++++++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/util/decal.ts b/src/util/decal.ts index fce20f366..b23795a65 100644 --- a/src/util/decal.ts +++ b/src/util/decal.ts @@ -23,13 +23,17 @@ const decalKeys = [ /** * Create or update pattern image from decal options * - * @param {InnerDecalObject} decalObject decal options - * @return {Pattern} pattern with generated image + * @param {InnerDecalObject | 'none'} decalObject decal options, 'none' if no decal + * @return {Pattern} pattern with generated image, null if no decal */ export function createOrUpdatePatternFromDecal( - decalObject: InnerDecalObject, + decalObject: InnerDecalObject | 'none', api: ExtensionAPI ): PatternObject { + if (decalObject === 'none') { + return null; + } + const dpr = api.getDevicePixelRatio(); const zr = api.getZr(); const isSVG = zr.painter.type === 'svg'; diff --git a/src/util/types.ts b/src/util/types.ts index 679f41080..933444163 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -871,7 +871,7 @@ export interface SymbolOptionMixin { export interface ItemStyleOption extends ShadowOptionMixin, BorderOptionMixin { color?: ZRColor opacity?: number - decal?: DecalObject[] + decal?: DecalObject | 'none' } /** diff --git a/test/decal.html b/test/decal.html index da1d9b62e..ab7bbf963 100644 --- a/test/decal.html +++ b/test/decal.html @@ -128,15 +128,25 @@ under the License. if (i === 0) { s.itemStyle = itemStyle; } + else if (i === 1) { + s.itemStyle = { + decal: 'none' + }; + } + else if (i === 2) { + s.data = [{ + value: s.data[0], + itemStyle: { + decal: 'none' + } + }]; + } series.push(s); var p = { name: 'pie' + i, value: i * 5 + 10 }; - if (i === 0) { - p.itemStyle = itemStyle; - } pieData.push(p); legendNames.push('bar' + i, 'pie' + i); @@ -175,7 +185,8 @@ under the License. title: [ 'It should use decal when aria.show is true', '(1) Each bar and pie piece should have different decal', - '(2) The first bar and pie piece decal should be blue' + '(2) The first bar decal should be blue', + '(3) The second and third bar should not have decal' ], option: option // height: 300, -- GitLab