From 88d830f4583421a42e2da7a6010e4771657d7d42 Mon Sep 17 00:00:00 2001 From: wisonic Date: Wed, 4 Sep 2024 19:25:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=A0=B7=E5=BC=8F=E8=83=8C=E6=99=AF=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E5=BA=A6=E4=B8=BA=200=20=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=BA=95=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/common/common_table.ts | 14 +++++++++-- .../src/views/chart/components/js/util.ts | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts index 0466a698ac..a5478e3e75 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts @@ -1,4 +1,11 @@ -import { copyString, hexColorToRGBA, isAlphaColor, parseJson, resetRgbOpacity } from '../..//util' +import { + copyString, + hexColorToRGBA, + isAlphaColor, + isTransparent, + parseJson, + resetRgbOpacity +} from '../..//util' import { DEFAULT_BASIC_STYLE, DEFAULT_TABLE_CELL, @@ -547,7 +554,10 @@ export function getConditions(chart: Chart) { return null } const fill = mappingColor(value, defaultBgColor, field, 'backgroundColor') - return fill ? { fill } : null + if (isTransparent(fill)) { + return null + } + return { fill } } }) } diff --git a/core/core-frontend/src/views/chart/components/js/util.ts b/core/core-frontend/src/views/chart/components/js/util.ts index 8573bb2ae4..e189e030d8 100644 --- a/core/core-frontend/src/views/chart/components/js/util.ts +++ b/core/core-frontend/src/views/chart/components/js/util.ts @@ -990,6 +990,30 @@ export function isAlphaColor(color: string): boolean { return false } +export function isTransparent(color: string): boolean { + if (!color?.trim()) { + return true + } + if (color.startsWith('#')) { + const tmp = color.substring(1, color.length) + if (tmp.length === 3 || tmp.length === 6) { + return false + } + if (tmp.length === 8) { + return tmp.substring(6, 8) === '00' + } + } + if (color.startsWith('rgb')) { + const tmp = color.split(',') + if (tmp.length !== 4) { + return false + } + const alpha = tmp[3].substring(0, tmp[3].length - 1) + return alpha.trim() === '0' + } + return false +} + export function convertToAlphaColor(color: string, alpha: number): string { if (!color?.trim()) { return 'rgba(255,255,255,1)'