Merge pull request #12026 from dataease/pr@dev-v2@fix_table_threshold_bg_color

fix(图表): 表格条件样式背景透明度为 0 时显示表格底色
This commit is contained in:
wisonic-s 2024-09-04 19:28:56 +08:00 committed by GitHub
commit 186339cc82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 2 deletions

View File

@ -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 }
}
})
}

View File

@ -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)'