diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts index 5fa23f90bf..4df495ecc9 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts @@ -701,10 +701,11 @@ export class Bar extends G2ChartView { const cColor = this.getColorByConditions([].concat(q), currentValue, chart) if (cColor) { item.conditionColor.push(cColor) - } else { - item.conditionColor = undefined } }) + if (!item.conditionColor.length) { + item.conditionColor = undefined + } }) return data } @@ -720,9 +721,10 @@ export class Bar extends G2ChartView { options.children[0].style = { ...options.children[0].style, fill: d => { - if (d.conditionColor) { - return d.conditionColor + if (d.conditionColor?.length) { + return d.conditionColor[0] } + return d.color } } return options