From 6998bf40d758aef4d94c18832db930bec52a219f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Falksk=C3=A4r?= <457523+edvard-falkskar@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:59:03 +0200 Subject: [PATCH] BarChart: Fix type error when there are no series (#89087) BarChart: Fix reference error when there are no series --- public/app/plugins/panel/barchart/BarChartPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/panel/barchart/BarChartPanel.tsx b/public/app/plugins/panel/barchart/BarChartPanel.tsx index 13555415e9d..4088029f4f4 100644 --- a/public/app/plugins/panel/barchart/BarChartPanel.tsx +++ b/public/app/plugins/panel/barchart/BarChartPanel.tsx @@ -92,7 +92,7 @@ export const BarChartPanel = (props: PanelProps) => { const xGroupsCount = vizSeries[0]?.length ?? 0; const seriesCount = vizSeries[0]?.fields.length ?? 0; - const totalSeries = info.series[0].fields.length - 1; + const totalSeries = Math.max(0, (info.series[0]?.fields.length ?? 0) - 1); let { builder, prepData } = useMemo( () => {