From c661077651ee689976803223ecd082c355432046 Mon Sep 17 00:00:00 2001 From: jackyin <648588267@qq.com> Date: Sun, 23 Mar 2025 03:44:48 +0800 Subject: [PATCH] Bar Chart: Crash when no number field exist (#102265) * fix bar chart crash * format * use optional chaining --- public/app/plugins/panel/barchart/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/panel/barchart/utils.ts b/public/app/plugins/panel/barchart/utils.ts index 9b25e678f1f..79d9629b11b 100644 --- a/public/app/plugins/panel/barchart/utils.ts +++ b/public/app/plugins/panel/barchart/utils.ts @@ -247,7 +247,7 @@ export const prepConfig = ({ series, totalSeries, color, orientation, options, t // use opacity from first numeric field let opacityField = frame.fields.find((f) => f.type === FieldType.number)!; - fillOpacity = (opacityField.config.custom.fillOpacity ?? 100) / 100; + fillOpacity = (opacityField?.config?.custom?.fillOpacity ?? 100) / 100; getColor = (seriesIdx: number, valueIdx: number) => { let field = frame.fields[seriesIdx];