From a411087dfd5b1564a024c06b930c3bfc2824d597 Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Sun, 27 Feb 2022 23:51:49 +0800 Subject: [PATCH 1/2] fix(sanky):fallback to black if color were illegal --- src/visual/VisualMapping.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/visual/VisualMapping.ts b/src/visual/VisualMapping.ts index 16c7394229..2af648c4de 100644 --- a/src/visual/VisualMapping.ts +++ b/src/visual/VisualMapping.ts @@ -28,6 +28,7 @@ import { VisualOptionUnit, ParsedValue } from '../util/types'; +import { warn } from '../util/log'; const each = zrUtil.each; const isObject = zrUtil.isObject; @@ -693,7 +694,11 @@ function setVisualToOption(thisOption: VisualMappingInnerOption, visualArr: Visu thisOption.visual = visualArr; if (thisOption.type === 'color') { thisOption.parsedVisual = zrUtil.map(visualArr, function (item: string) { - return zrColor.parse(item); + const color = zrColor.parse(item); + if (!color && __DEV__) { + warn(`'${item}' is an illegal color, fallback to '#000000'`, true); + } + return zrColor.parse(item) || [0, 0, 0, 1]; }); } return visualArr; From c572d102c2804bfde33abbe0e4fea34a9ec6b199 Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Wed, 2 Mar 2022 22:59:17 +0800 Subject: [PATCH 2/2] fix(sankey): return cached value --- src/visual/VisualMapping.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/visual/VisualMapping.ts b/src/visual/VisualMapping.ts index 2af648c4de..8898bc7b06 100644 --- a/src/visual/VisualMapping.ts +++ b/src/visual/VisualMapping.ts @@ -698,7 +698,7 @@ function setVisualToOption(thisOption: VisualMappingInnerOption, visualArr: Visu if (!color && __DEV__) { warn(`'${item}' is an illegal color, fallback to '#000000'`, true); } - return zrColor.parse(item) || [0, 0, 0, 1]; + return color || [0, 0, 0, 1]; }); } return visualArr;