Skip to content

Commit e508645

Browse files
kgabryjeclaude
andcommitted
fix(heatmap): correct tooltip display to show axis values instead of indices
The tooltip was showing numeric indices (0, 1, 2...) instead of the actual axis values after PR #36302 changed the data structure to use indices. This fix looks up the actual x/y axis values from the sorted arrays before formatting them for display in the tooltip. Also fixes percentage calculation to use actual values instead of indices when normalizeAcross is enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a6c0d63 commit e508645

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

superset-frontend/plugins/plugin-chart-echarts/src/Heatmap/transformProps.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,32 @@ export default function transformProps(
370370
metricLabel,
371371
);
372372
const paramsValue = params.value as (string | number)[];
373-
const x = paramsValue?.[0];
374-
const y = paramsValue?.[1];
373+
// paramsValue contains [xIndex, yIndex, metricValue, rankValue?]
374+
// We need to look up the actual axis values from the sorted arrays
375+
const xIndex = paramsValue?.[0] as number;
376+
const yIndex = paramsValue?.[1] as number;
375377
const value = paramsValue?.[2] as number | null | undefined;
376-
const formattedX = xAxisFormatter(x);
377-
const formattedY = yAxisFormatter(y);
378+
const xValue = sortedXAxisValues[xIndex];
379+
const yValue = sortedYAxisValues[yIndex];
380+
// Format the axis values for display (handle null/undefined with empty string fallback)
381+
// Convert to string/number for formatter compatibility
382+
const formattedX =
383+
xValue !== null && xValue !== undefined
384+
? xAxisFormatter(xValue as string | number)
385+
: '';
386+
const formattedY =
387+
yValue !== null && yValue !== undefined
388+
? yAxisFormatter(yValue as string | number)
389+
: '';
378390
const formattedValue = valueFormatter(value);
379391
let percentage = 0;
380392
let suffix = 'heatmap';
381393
if (typeof value === 'number') {
382394
if (normalizeAcross === 'x') {
383-
percentage = value / totals.x[x];
395+
percentage = value / totals.x[String(xValue)];
384396
suffix = formattedX;
385397
} else if (normalizeAcross === 'y') {
386-
percentage = value / totals.y[y];
398+
percentage = value / totals.y[String(yValue)];
387399
suffix = formattedY;
388400
} else {
389401
percentage = value / totals.total;

0 commit comments

Comments
 (0)