# Waterfall (/docs/charts/waterfall)

Waterfall answers "how did the deltas compose into the total?" — the P&L bridge, in a cell. Sign is encoded by vertical
direction from the running level AND by valence color, never color alone.

```tsx
<Waterfall
  data={[
    { label: "Product", value: 42 },
    { label: "Services", value: 18 },
    { label: "Refunds", value: -12 },
    { label: "Opex", value: -26 },
    { label: "FX", value: 5 },
  ]}
  open={60}
  title="Net income bridge"
  width={220}
  height={30}
/>
```

## Install

```tsx
import { Waterfall } from "@microcharts/react/waterfall";

<Waterfall data={steps} open={60} title="Net income bridge" />
```

Setup (package + stylesheet): [Quickstart](/docs/quickstart#set-up-with-an-ai-agent) or paste [`/agent-setup.md`](/agent-setup.md) into your agent.


## When to use it

- **Good for** — P&L bridges in table cells, net-change decomposition in KPI cards.
- **Avoid for** — unordered category comparison (MiniBar), or more than ~8 steps.


## Variants

```tsx
// label="delta" is the default — each step's signed value sits in a band below
// the plot. When labels would collide, the biggest movers win — a deterministic
// drop-out, never a random overlap. Pass label="none" to drop the band.
<Waterfall data={steps} open={60} />
<Waterfall data={steps} open={60} totalBar={false} />
```

```tsx
// cost breakdowns invert valence — decreases are wins
<Waterfall
  data={[
    { label: "Cloud", value: -8 },
    { label: "Headcount", value: 14 },
    { label: "Vendors", value: -5 },
    { label: "Travel", value: -3 },
  ]}
  open={40}
  positive="down"
/>
```

## Edge cases

```tsx
// a bridge that only falls — the domain extends below zero and the
// zero-anchored total bar hangs beneath the baseline
<Waterfall
  data={[
    { label: "Q1", value: -20 },
    { label: "Q2", value: -35 },
    { label: "Q3", value: -10 },
  ]}
  open={0}
/>
```

```tsx
// a zero delta renders a visible 1-unit neutral tick at the running level —
// "no change" is a statement, not a gap
<Waterfall
  data={[
    { label: "Product", value: 30 },
    { label: "Flat", value: 0 },
    { label: "Refunds", value: -12 },
  ]}
  open={50}
/>
```


## Why this default

The zero-anchored total bar stays on by default: a waterfall without a grounded total is unverifiable — floating bars
alone can't be checked against reality. Hairline connectors carry the running level between steps without adding ink.

## Accessibility

The accessible name states the endpoints and the split — **"From 60 to 87 over 5 steps: +65 gains, −38 losses."** The
interactive entry steps through the bridge (**"Refunds: −12, running 108."**).

The interactive entry follows the shared [interaction contract](/docs/accessibility#one-interaction-contract):
arrow keys rove between units on both axes, `Home` and `End` jump to the ends, and a click, tap, `Enter` or
`Space` selects a unit — pinning its readout so it survives blur, until you select it again or press `Escape`.
On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` (required) | `{ label; value }[]` | Signed deltas in order. |
| `open` | `number` | Opening level (prior-period close). |
| `totalBar` | `boolean` | Zero-anchored closing total bar (default on). |
| `positive` | `"up" \| "down"` | "down" = decreases are good (cost breakdowns). |
| `label` | `"none" \| "delta"` | "delta" (default) prints each step's signed value in a band below the plot; the biggest movers win when labels would collide. |
| `animate` | `boolean` | (interactive) Opt-in entrance motion when the chart mounts client-side — add `import "@microcharts/react/motion"` once. Inert on the server, on hydrated server HTML, and under `prefers-reduced-motion`. |

Plus the shared grammar — `data`, `domain`, `color`, `title`, `summary`, `format` — and the layout props (`width`, `height`, `className`, `style`) that every chart accepts. Interactive entries also share `animate` and `live`, and — wherever a chart has more than one navigable unit — `onActive`, `onSelect`, `selectedIndex` and `defaultSelectedIndex`; and — wherever the chart shows a hover value — `readout`. See [the shared grammar](/docs/quickstart#the-shared-grammar).
