diff --git a/src/util/decal.ts b/src/util/decal.ts index fce20f36605fba7e3c63d594602cadc314f67178..b23795a65435d71295829cdeb05427bfb3258794 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 679f41080f0b615377574f8cb6957db32222315e..9334441631cf0387727773c1b77d1f4ca8553c6a 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 da1d9b62e02f7e4c32961dc695ac543b7b6034a4..ab7bbf963ad7567f33db0cb1d05d6a819c477bcd 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,