Skip to content

Commit 536d30b

Browse files
fix(big-number): guard against null colorPicker in transformProps
colorPicker defaults to null when the colour-picker control has never been set (e.g. a freshly-created Big Number chart). Destructuring it directly crashes: TypeError: Cannot destructure property 'r' of 'colorPicker' as it is null When colorPicker is null/undefined, mainColor is now left undefined so that BigNumberViz falls back to its existing BRAND_COLOR default. The ECharts trendline options fall back to BRAND_COLOR explicitly since they require a string value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent aa5adb0 commit 536d30b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline

superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
import { t } from '@apache-superset/core/translation';
2020
import {
21+
BRAND_COLOR,
2122
extractTimegrain,
2223
getNumberFormatter,
2324
NumberFormats,
@@ -140,8 +141,9 @@ export default function transformProps(
140141
const compareLag = Number(compareLag_) || 0;
141142
let formattedSubheader = subheader;
142143

143-
const { r, g, b } = colorPicker;
144-
const mainColor = `rgb(${r}, ${g}, ${b})`;
144+
const mainColor = colorPicker
145+
? `rgb(${colorPicker.r}, ${colorPicker.g}, ${colorPicker.b})`
146+
: undefined;
145147

146148
const xAxisLabel = getXAxisLabel(rawFormData) as string;
147149
let trendLineData: TimeSeriesDatum[] | undefined;
@@ -290,12 +292,12 @@ export default function transformProps(
290292
symbol: 'circle',
291293
symbolSize: 10,
292294
showSymbol: false,
293-
color: mainColor,
295+
color: mainColor ?? BRAND_COLOR,
294296
areaStyle: {
295297
color: new graphic.LinearGradient(0, 0, 0, 1, [
296298
{
297299
offset: 0,
298-
color: mainColor,
300+
color: mainColor ?? BRAND_COLOR,
299301
},
300302
{
301303
offset: 1,

0 commit comments

Comments
 (0)