You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/06/04 19:29:55 UTC
(superset) branch master updated: fix(echarts): Show full labels in bar chart tooltips (#34759)
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 639866625db fix(echarts): Show full labels in bar chart tooltips (#34759)
639866625db is described below
commit 639866625db541d5d02d714beb86abe08dfc9bba
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Thu Jun 4 12:29:48 2026 -0700
fix(echarts): Show full labels in bar chart tooltips (#34759)
Co-authored-by: Claude Opus 4.5 <no...@anthropic.com>
---
.../src/Timeseries/transformProps.ts | 6 +-
.../test/Timeseries/transformProps.test.ts | 97 ++++++++++++++++++++++
2 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
index 1086c5f6a8c..4a0b8f5baf6 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
@@ -1016,8 +1016,12 @@ export default function transformProps(
trigger: richTooltip ? 'axis' : 'item',
formatter: (params: any) => {
const [xIndex, yIndex] = isHorizontal ? [1, 0] : [0, 1];
+ // For axis tooltips, prefer axisValue/axisValueLabel which contains the full label
+ // even when the axis label is visually truncated
const xValue: number = richTooltip
- ? params[0].value[xIndex]
+ ? (params[0].axisValue ??
+ params[0].axisValueLabel ??
+ params[0].value[xIndex])
: params.value[xIndex];
const forecastValue: CallbackDataParams[] = richTooltip
? params
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
index 78434f33a40..e3b8724951c 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
@@ -1657,3 +1657,100 @@ test('should assign distinct dash patterns for multiple time offsets consistentl
// must be different patterns
expect(symbol1).not.toEqual(symbol2);
});
+
+describe('Tooltip with long labels', () => {
+ test('should use axisValue for tooltip when available (richTooltip)', () => {
+ const longLabelData: ChartDataResponseResult[] = [
+ createTestQueryData([
+ {
+ 'This is a very long category name that would normally be truncated': 100,
+ __timestamp: 599616000000,
+ },
+ {
+ 'Another extremely long category name for testing purposes': 200,
+ __timestamp: 599916000000,
+ },
+ ]),
+ ];
+
+ const chartProps = createTestChartProps({
+ formData: {
+ richTooltip: true,
+ },
+ queriesData: longLabelData,
+ });
+
+ const transformedProps = transformProps(chartProps);
+
+ // Get the tooltip formatter function
+ const tooltipFormatter = (transformedProps.echartOptions as any).tooltip
+ .formatter;
+
+ // Simulate params from ECharts with axisValue containing full label
+ // Use distinct values for axisValue and seriesName to verify axisValue is used
+ const mockParams = [
+ {
+ axisValue:
+ 'This is a very long category name that would normally be truncated',
+ value: [599616000000, 100],
+ seriesName: 'Some Series Name',
+ },
+ ];
+
+ // Call the formatter and check it uses the full label from axisValue
+ const result = tooltipFormatter(mockParams);
+ expect(result).toContain(
+ 'This is a very long category name that would normally be truncated',
+ );
+ });
+
+ test('should fallback to value when axisValue is not available', () => {
+ const chartProps = createTestChartProps({
+ formData: {
+ richTooltip: true,
+ },
+ });
+
+ const transformedProps = transformProps(chartProps);
+
+ const tooltipFormatter = (transformedProps.echartOptions as any).tooltip
+ .formatter;
+
+ // Simulate params without axisValue
+ const mockParams = [
+ {
+ value: [599616000000, 1],
+ seriesName: 'San Francisco',
+ },
+ ];
+
+ // Should fall back to the x-value (value[xIndex]) and render it in the title
+ const result = tooltipFormatter(mockParams);
+ expect(typeof result).toBe('string');
+ expect(result).toContain('599616000000');
+ });
+
+ test('should handle item tooltips correctly', () => {
+ const chartProps = createTestChartProps({
+ formData: {
+ richTooltip: false,
+ },
+ });
+
+ const transformedProps = transformProps(chartProps);
+
+ const tooltipFormatter = (transformedProps.echartOptions as any).tooltip
+ .formatter;
+
+ // For item tooltips, params is a single object
+ const mockParams = {
+ value: [599616000000, 1],
+ seriesName: 'San Francisco',
+ };
+
+ // The item-tooltip x-value (value[xIndex]) should appear in the title
+ const result = tooltipFormatter(mockParams);
+ expect(typeof result).toBe('string');
+ expect(result).toContain('599616000000');
+ });
+});