From 4ad642ad9999769f85fd5cf6c19d1747e26417b3 Mon Sep 17 00:00:00 2001 From: Omkar Kesarkhane <127078473+omkarK06@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:07:56 +0530 Subject: [PATCH] fix: Bar Chart not rendering as expected when breakdown is present (#5624) #5597 ## Summary by CodeRabbit - **Bug Fixes** - Improved label retrieval process to handle cases with undefined axis keys. - Enhanced series generation logic for bar and horizontal bar charts. These updates ensure a more reliable experience when processing chart configurations in the dashboard. --- web/src/utils/dashboard/convertSQLData.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/web/src/utils/dashboard/convertSQLData.ts b/web/src/utils/dashboard/convertSQLData.ts index 8b22f3cc98..2aea39ce45 100644 --- a/web/src/utils/dashboard/convertSQLData.ts +++ b/web/src/utils/dashboard/convertSQLData.ts @@ -1190,7 +1190,11 @@ export const convertSQLData = async ( panelSchema.type == "h-stacked") && panelSchema.queries[0].fields.breakdown?.length) ) { - return yAxisKeys.length === 1 ? xAXisKey : `${xAXisKey} (${label})`; + return yAxisKeys.length === 1 + ? xAXisKey + ? xAXisKey + : label + : `${xAXisKey} (${label})`; } return label; @@ -1214,7 +1218,8 @@ export const convertSQLData = async ( if ( breakDownKeys.length && - (panelSchema.type === "bar" || panelSchema.type === "h-bar") + (panelSchema.type === "bar" || panelSchema.type === "h-bar") && + !panelSchema.config.trellis?.layout ) { const seriesData = getAxisDataFromKey(yAxis); return getSeriesObj(yAxisName, seriesData, seriesConfig); @@ -2097,9 +2102,7 @@ export const convertSQLData = async ( } }); - options.xAxis.forEach((it: any) => { - it.type = "time"; - }); + options.xAxis[0].type = "time"; options.xAxis[0].data = [];