Charts
WaterfallChart
How a start value becomes an end value through increases and decreases — profit bridges, headcount, budgets.
import '@reactloom/charts/styles.css';
import { WaterfallChart } from '@reactloom/charts';Examples
Profit bridge
- increase
- decrease
- total
Use the arrow keys to move between data points, Home and End to jump to the first and last.
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.
- joined
- left
- total
Use the arrow keys to move between data points, Home and End to jump to the first and last.
| Category | Change | Running total |
|---|---|---|
| Start of year | +84 | 84 |
| Hires | +23 | 107 |
| Leavers | −9 | 98 |
| Transfers in | +4 | 102 |
| End of year | 102 |
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
| Prop | Type | Default |
|---|---|---|
datarequired | Row[] | — |
labelrequired | key or accessor | — |
valuerequiredThe change at each step. | key or accessor | — |
isTotalRows that show the running total. | (row) => boolean | — |
titlerequiredNames the figure. | string | — |
descriptionThe takeaway; a factual summary is generated when omitted. | ReactNode | — |
tableThe data table alternative. | 'toggle' | 'visible' | 'none' | 'toggle' |
height · valueFormat · formatValue · messagesAs 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.
| Attribute | Values |
|---|---|
[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.
| Key | Action |
|---|---|
| Tab | Focus the plot |
| ← → ↑ ↓ | Move between items |
| Home / End | First / last item |
| Escape | Clear the highlight |
Usage guidelines
Do
- End with a total.
Don’t
- Don't mix units in one waterfall.