Examples

Profit bridge

Preview
Profit bridge (k€)Waterfall chart of 7 steps, ending at 350.
  • increase
  • decrease
  • total
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Example.tsx
import { WaterfallChart } from '@reactloom/charts';

const bridge = [
  { step: 'Revenue', amount: 1200 },
  { step: 'Cost of sales', amount: -480 },
  { step: 'Gross profit', amount: 0, total: true },
  { step: 'Salaries', amount: -320 },
  { step: 'Marketing', amount: -110 },
  { step: 'Grants', amount: 60 },
  { step: 'Net profit', amount: 0, total: true },
];

export default function Example() {
  return <WaterfallChart title="Profit bridge (k€)" data={bridge} label="step" value="amount" isTotal={(r) => Boolean(r.total)} />;
}

Headcount change

messages renames increases and decreases.

Preview
HeadcountWaterfall chart of 5 steps, ending at 102.
  • joined
  • left
  • total
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Headcount (data)
CategoryChangeRunning total
Start of year+8484
Hires+23107
Leavers−998
Transfers in+4102
End of year102
Example.tsx
import { WaterfallChart } from '@reactloom/charts';

const changes = [
  { label: 'Start of year', change: 84 },
  { label: 'Hires', change: 23 },
  { label: 'Leavers', change: -9 },
  { label: 'Transfers in', change: 4 },
  { label: 'End of year', change: 0, total: true },
];

export default function Example() {
  return <WaterfallChart title="Headcount" data={changes} label="label" value="change" isTotal={(r) => Boolean(r.total)} table="visible" messages={{ increase: 'joined', decrease: 'left' }} />;
}

API reference

WaterfallChart props
PropTypeDefault
datarequired
Row[]—
labelrequired
key or accessor—
valuerequired
The change at each step.
key or accessor—
isTotal
Rows that show the running total.
(row) => boolean—
titlerequired
Names the figure.
string—
description
The takeaway; a factual summary is generated when omitted.
ReactNode—
table
The data table alternative.
'toggle' | 'visible' | 'none''toggle'
height · valueFormat · formatValue · messages
As on the other charts.
—

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-active]present when on

Theme tokens it reads

--pl-color-border-strong --pl-color-fg-default --pl-color-fg-muted

Accessibility

  • The chart is a figure named by its title and described by a summary; the drawing is hidden from assistive technology.
  • The plot is one tab stop: arrow keys move between items and each is announced; the data table gives every value.
  • Increases and decreases are named in words (and shown with a sign in the table), not only by colour.
Keyboard interactions
KeyAction
TabFocus the plot
← → ↑ ↓Move between items
Home / EndFirst / last item
EscapeClear the highlight

Usage guidelines

Do

  • End with a total.

Don’t

  • Don't mix units in one waterfall.