From 9845a2ee1910010ce6874884cee97d5e8194450c Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Wed, 25 Mar 2026 18:54:44 +0100 Subject: [PATCH] Fix waterfall chart bar labels showing wrong value for negative bars Use datum.value instead of Recharts' props.value for bar labels. For stacked bars, props.value is the cumulative stack-top, not the individual bar's value, causing negative bars to display incorrect labels. Fixes #863 Co-Authored-By: Claude Opus 4.6 --- app/src/components/charts/WaterfallChart.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/components/charts/WaterfallChart.tsx b/app/src/components/charts/WaterfallChart.tsx index aa7d28567..0bc0b85fe 100644 --- a/app/src/components/charts/WaterfallChart.tsx +++ b/app/src/components/charts/WaterfallChart.tsx @@ -120,7 +120,9 @@ export function WaterfallChart({ const y = props.y as number; const w = props.width as number; const h = props.height as number; - const value = props.value as number; + // Use the datum's value, not props.value — Recharts gives the + // cumulative stack-top for stacked bars, which is wrong for labels. + const datum = data[idx]; // Store this bar's pixel rect for the next bar's connector barPositions[idx] = { x, y, width: w, height: h }; @@ -137,7 +139,7 @@ export function WaterfallChart({ const barHeight = Math.abs(h); const showLabel = showBarLabels && barHeight >= 20; - const text = barLabelFormatter ? barLabelFormatter(value) : String(value); + const text = barLabelFormatter ? barLabelFormatter(datum.value) : datum.label; return (