# Waterfall Chart

> Show how a starting value becomes an ending value through a sequence of increases and decreases.

Source: https://www.honestui.com/docs/charts/waterfall-chart/static

### Operating income bridge

```tsx
"use client";

import { WaterfallChart, type ChartConfig } from "honestui/charts";

// Scenario: Quarterly operating income bridge, in thousands
const data = [
  { step: "Revenue", amount: 1840, isTotal: true },
  { step: "Cost of goods", amount: -612 },
  { step: "Gross profit", isTotal: true },
  { step: "Salaries", amount: -428 },
  { step: "Marketing", amount: -186 },
  { step: "Services", amount: 94 },
  { step: "Rent", amount: -72 },
  { step: "Operating income", isTotal: true },
];

const chartConfig = {
  increase: { label: "Increase", colors: { light: ["#16a34a"], dark: ["#22c55e"] } },
  decrease: { label: "Decrease", colors: { light: ["#dc2626"], dark: ["#f87171"] } },
  total: { label: "Total", colors: { light: ["#2563eb"], dark: ["#3b82f6"] } },
} satisfies ChartConfig;

export function ExampleWaterfallChart() {
  return (
    <WaterfallChart
      data={data}
      config={chartConfig}
      xDataKey="step"
      valueDataKey="amount"
      totalDataKey="isTotal"
      className="h-full w-full p-4"
    >
      <WaterfallChart.Grid />
      <WaterfallChart.XAxis />
      <WaterfallChart.YAxis tickFormatter={(value) => `$${value}k`} />
      <WaterfallChart.Legend />
      <WaterfallChart.Tooltip valueFormatter={(value) => `$${value.toLocaleString()}k`} />
      <WaterfallChart.Bars />
    </WaterfallChart>
  );
}

```

## Overview [#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 [#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 [#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 [#installation]

<CommandBlock commands="[&#x22;honestui&#x22;]" />

## Usage [#usage]

```tsx
import { WaterfallChart, type ChartConfig } from "honestui/charts";
```

```tsx
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 [#examples]

### Value Labels [#value-labels]

### showValues

```tsx
"use client";

import { WaterfallChart, type ChartConfig } from "honestui/charts";

// Scenario: Monthly active users, from start of month to end of month
const data = [
  { change: "Start", users: 48200, total: true },
  { change: "New sign-ups", users: 6350 },
  { change: "Reactivated", users: 1820 },
  { change: "Churned", users: -4170 },
  { change: "Dormant", users: -2240 },
  { change: "End", total: true },
];

const chartConfig = {
  increase: { label: "Gained", colors: { light: ["#0d9488"], dark: ["#2dd4bf"] } },
  decrease: { label: "Lost", colors: { light: ["#e11d48"], dark: ["#fb7185"] } },
  total: { label: "Active users", colors: { light: ["#334155"], dark: ["#cbd5e1"] } },
} satisfies ChartConfig;

const compact = (value: number) =>
  value.toLocaleString("en-US", { notation: "compact", maximumFractionDigits: 1 });

export function ExampleValuesWaterfallChart() {
  return (
    <WaterfallChart
      data={data}
      config={chartConfig}
      xDataKey="change"
      valueDataKey="users"
      totalDataKey="total"
      className="h-full w-full p-4"
    >
      <WaterfallChart.Grid />
      <WaterfallChart.XAxis />
      <WaterfallChart.Tooltip valueFormatter={(value) => value.toLocaleString()} />
      <WaterfallChart.Bars
        showValues
        radius={4}
        width={0.5}
        valueFormatter={(value, kind) =>
          kind === "total" ? compact(value) : `${value > 0 ? "+" : "−"}${compact(Math.abs(value))}`
        }
      />
    </WaterfallChart>
  );
}

```

`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 [#reference-line]

<ComponentPreview title="<WaterfallChart.ReferenceLine />" name="ex-reference-lines-echarts-waterfall-chart" />

A `ReferenceLine` at the plan or budget shows where the result lands against it. `ReferenceArea` and `ReferenceDot` work the same way; see [Reference Lines](/docs/charts/ui/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 [#loading-state]

### isLoading='true'

```tsx
"use client";

import { WaterfallChart, type ChartConfig } from "honestui/charts";

const chartConfig = {
  increase: { label: "Increase", colors: { light: ["#16a34a"], dark: ["#22c55e"] } },
  decrease: { label: "Decrease", colors: { light: ["#dc2626"], dark: ["#f87171"] } },
  total: { label: "Total", colors: { light: ["#2563eb"], dark: ["#3b82f6"] } },
} satisfies ChartConfig;

export function ExampleLoadingWaterfallChart() {
  return (
    <WaterfallChart
      data={[]}
      config={chartConfig}
      xDataKey="step"
      valueDataKey="amount"
      isLoading
      className="h-full w-full p-4"
    >
      <WaterfallChart.Grid />
      <WaterfallChart.Bars />
    </WaterfallChart>
  );
}

```

`isLoading` reserves the plot with a neutral bridge silhouette and the shared loading label.

## API Reference [#api-reference]

<ApiHeading>
  WaterfallChart
</ApiHeading>


  ### `data`

type: `TData[]`

One row per step, in order.

  ### `config`

type: `ChartConfig`

Labels and colors for `increase`, `decrease`, and `total`.

  ### `xDataKey`

type: `keyof TData & string`

The step name.

  ### `valueDataKey`

type: `keyof TData & string`

The change each step contributes. On a total row, an optional value that resets the running total.

  ### `totalDataKey`

type: `keyof TData & string`

A boolean field that marks total and subtotal rows.

  ### `animation`

type: `boolean` · default: `true`

Fades the bars in from left to right. Reduced-motion preferences turn it off.

  ### `isLoading`

type: `boolean` · default: `false`

Shows the loading silhouette and label.

  ### `syncId`

type: `string`

Charts with the same id move their tooltip together, matched by step name.

  ### `ariaLabel`

type: `string`

Accessible name for the canvas. A summary with the final total is generated when omitted.

  ### `chartOptions`



">
    Escape hatch merged over the generated ECharts option.


<ApiHeading>
  Bars
</ApiHeading>


  ### `radius`

type: `number` · default: `2`

Corner radius in pixels.

  ### `width`

type: `number` · default: `0.6`

Bar width as a share of each category.

  ### `connectors`

type: `boolean` · default: `true`

Draws dashed connectors at the running total between bars.

  ### `showValues`

type: `boolean` · default: `false`

Prints each change beside its bar.

  ### `valueFormatter`



string">
    Formats the printed values.


<ApiHeading>
  XAxis / YAxis
</ApiHeading>


  ### `tickFormatter`



string">
    Formats tick labels. Steps are strings and values are numbers.

  ### `label`

type: `string`

Axis title.

  ### `hideDots`

type: `boolean` · default: `false`

Hides the tick dots.


<ApiHeading>
  Tooltip
</ApiHeading>


  ### `variant`

type: `&#x22;default&#x22; | &#x22;frosted-glass&#x22;` · default: `&#x22;default&#x22;`

Tooltip surface.

  ### `roundness`

type: `&#x22;sm&#x22; | &#x22;md&#x22; | &#x22;lg&#x22; | &#x22;xl&#x22;` · default: `&#x22;lg&#x22;`

Tooltip corner radius.

  ### `position`

type: `&#x22;fixed&#x22; | &#x22;variable&#x22;` · default: `&#x22;variable&#x22;`

Pins the tooltip to the top or lets it follow the pointer.

  ### `cursor`

type: `boolean` · default: `false`

Draws the dashed line at the hovered step.

  ### `valueFormatter`



string">
    Formats the change and the running total.

  ### `defaultIndex`

type: `number`

Opens the tooltip at a step after mount.


<ApiHeading>
  Legend
</ApiHeading>


  ### `variant`

type: `LegendVariant` · default: `&#x22;rounded-square&#x22;`

Indicator shape. Only kinds present in the data are listed.

  ### `align`

type: `&#x22;left&#x22; | &#x22;center&#x22; | &#x22;right&#x22;` · default: `&#x22;right&#x22;`

Horizontal alignment.

  ### `verticalAlign`

type: `&#x22;top&#x22; | &#x22;middle&#x22; | &#x22;bottom&#x22;` · default: `&#x22;top&#x22;`

Vertical placement.


<ApiHeading>
  ReferenceLine, ReferenceArea, ReferenceDot
</ApiHeading>

Take the props listed in [Reference Lines](/docs/charts/ui/reference-lines). Pass a step name for `x` and an amount for `y`.

<ApiHeading>
  computeWaterfall
</ApiHeading>

`computeWaterfall(data, xKey, valueKey, totalKey?)` returns one `WaterfallStep` per row with its `kind`, `value`, `start`, `end`, and `runningTotal`, the same numbers the chart draws.
