From 1bff6264c898fdf3048d6f444e27e05a22d1c972 Mon Sep 17 00:00:00 2001 From: Siddhant Singh Date: Sat, 1 Nov 2025 17:10:33 +0530 Subject: [PATCH] Fix horizontal bar chart bar names and tooltip display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes two issues with horizontal bar charts: 1. Bar names not showing: The backend transform_data_for_chart function was only returning xAxisData, but horizontal bar charts need yAxisData for the category axis (bar names). 2. Tooltip not working on hover: With missing axis data, tooltips could not properly display when hovering over bars. Changes: - Added yAxisData to all bar chart data transformation return values - Updated raw data bar charts to include both xAxisData and yAxisData - Updated aggregated bar charts (with/without extra dimension) to include both axis data arrays - Category data is now available for both vertical (xAxis) and horizontal (yAxis) orientations The ECharts config generator already correctly uses yAxisData for horizontal bars (line 161), so this provides the missing data. Files modified: - ddpui/core/charts/charts_service.py: Added yAxisData to transform functions for bar charts (lines 708-710, 793-797, 829-834) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- ddpui/core/charts/charts_service.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ddpui/core/charts/charts_service.py b/ddpui/core/charts/charts_service.py index d76a50f3..61c8ef8d 100644 --- a/ddpui/core/charts/charts_service.py +++ b/ddpui/core/charts/charts_service.py @@ -699,11 +699,14 @@ def transform_data_for_chart( if payload.chart_type == "bar": if payload.computation_type == "raw": + # Get category data (bar names) + category_data = [ + convert_value(safe_get_value(row, payload.x_axis, null_label)) for row in results + ] + return { - "xAxisData": [ - convert_value(safe_get_value(row, payload.x_axis, null_label)) - for row in results - ], + "xAxisData": category_data, # For vertical bars + "yAxisData": category_data, # For horizontal bars "series": [ { "name": payload.y_axis, @@ -787,7 +790,8 @@ def transform_data_for_chart( legend_data.append(dimension) return { - "xAxisData": x_axis_data, + "xAxisData": x_axis_data, # For vertical bars + "yAxisData": x_axis_data, # For horizontal bars "series": series_data, "legend": legend_data, } @@ -823,7 +827,8 @@ def transform_data_for_chart( legend_data.append(display_name) return { - "xAxisData": x_axis_data, + "xAxisData": x_axis_data, # For vertical bars + "yAxisData": x_axis_data, # For horizontal bars "series": series_data, "legend": legend_data, }