Waterfall Chart
Show how a starting value becomes an ending value through a sequence of increases and decreases.
Overview
Use a waterfall chart, also called a bridge chart, to explain a change between two totals: how revenue became operating income, how last month's users became this month's, or how a budget was spent. Each step floats from where the previous one ended, so the size of every contribution and the running total are both visible.
Rows are ordered steps. Most rows carry a change. Rows marked as totals span from zero to the running total, for subtotals and the final result. A total row with a value resets the running total to it, which is how an opening balance is set.
Anatomy
WaterfallChart computes the running total from data and owns the axes and loading state. Bars draws the floating bars, dashed connectors that carry the running total from one bar to the next, and optional value labels. Add XAxis, YAxis, Grid, Legend, and Tooltip for context.
Colors come from three config keys: increase, decrease, and total. Bars that cross zero are drawn correctly, because every bar is a range from its start to its end, not a stack on a hidden base.
Accessibility
Do not rely on green and red alone: label the steps clearly, consider showValues so each change is printed with its sign, and choose colors that differ in lightness. The canvas exposes only its accessible name, which by default reports the number of steps and the final total. computeWaterfall returns exactly what the chart draws, so the same steps can fill a nearby table.
Installation
Usage
import { WaterfallChart, type ChartConfig } from "honestui/charts";const data = [
{ step: "Revenue", amount: 1840, isTotal: true },
{ step: "Cost of goods", amount: -612 },
{ step: "Gross profit", isTotal: true },
{ step: "Salaries", amount: -428 },
{ step: "Operating income", isTotal: true },
];
const chartConfig = {
increase: { label: "Increase", colors: { light: ["#16a34a"] } },
decrease: { label: "Decrease", colors: { light: ["#dc2626"] } },
total: { label: "Total", colors: { light: ["#2563eb"] } },
} satisfies ChartConfig;
<WaterfallChart
data={data}
config={chartConfig}
xDataKey="step"
valueDataKey="amount"
totalDataKey="isTotal"
>
<WaterfallChart.Grid />
<WaterfallChart.XAxis />
<WaterfallChart.YAxis />
<WaterfallChart.Tooltip />
<WaterfallChart.Bars />
</WaterfallChart>The tooltip shows each step's change with its sign and the running total after it.
Examples
Value Labels
showValues prints each change above rising bars and below falling ones. Use valueFormatter to shorten large numbers; it receives the bar's kind so totals can be written without a sign.
Reference Line
A ReferenceLine at the plan or budget shows where the result lands against it. ReferenceArea and ReferenceDot work the same way; see Reference Lines. Give several waterfalls, or a waterfall and a bar chart over the same steps, one syncId to move their tooltips together.
Loading State
isLoading reserves the plot with a neutral bridge silhouette and the shared loading label.
API Reference
Take the props listed in Reference Lines. Pass a step name for x and an amount for y.
computeWaterfall(data, xKey, valueKey, totalKey?) returns one WaterfallStep per row with its kind, value, start, end, and runningTotal, the same numbers the chart draws.