Data viz
Sankey
A flow diagram: quantities move left-to-right through stages, and the width of every ribbon is the amount that flows along it. Use it to trace how work splits and recombines — type → team → outcome, source → channel → conversion. Hover any node to isolate its flows.
npx shadcn@latest add @orbit/sankey-chartOverview
Live — hover a node to fade everything except the ribbons that touch it, and follow one type or team across the board.
Reading it
Every node’s height and every ribbon’s thickness map to the same scale, so flow is conserved: what enters a node leaves it.
Stages & colors
Any number of stages, two and up. Nodes without an explicit color fall back to the fixed CHART_SERIES palette by row within their stage — color follows the entity across the whole diagram.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| stages | SankeyNode[][] | — | Nodes per stage, left to right. { id, label, color? } — color defaults to CHART_SERIES by row within the stage. |
| links | { source: string; target: string; value: number }[] | — | Flows between adjacent stages. Ribbon slices stack top-to-bottom in array order; ribbons take the source node’s color. |
| height | number | 384 | Total height in px. Width is responsive. |
| nodeWidth | number | 13 | Width of the node bars. |
| nodeGap | number | 17 | Vertical gap between stacked nodes in a stage. |
| showTooltip | boolean | true | Dark tooltip on hovered nodes (total) and ribbons (flow). |
| formatValue | (v: number) => string | String | Formats node and tooltip values. |
| ariaLabel | string | — | Plain-language summary for the chart’s role=“img”. |
| …rest | HTMLAttributes<HTMLDivElement> | — | Forwarded to the root div, including ref and className. |
Usage
A Sankey shines at 2–4 stages and a handful of nodes per stage. Past that it turns to spaghetti — aggregate small flows into an “Other” band.
Keep stages few
Two to four columns reads cleanly. Each added stage multiplies crossings and erodes the “follow the flow” clarity.
Show dozens of nodes
Beyond ~6 per column the ribbons tangle. Roll small categories into an “Other” node and let people drill in.
Colour by origin
Tint ribbons by their source so a flow keeps its identity across the whole diagram, even after it merges.
Use it for time series
Sankey is for flow between categories, not change over time. For trends, reach for line, area or cumulative-flow charts.
Keyboard & accessibility
The chart renders as a labelled image; every node carries its name and value directly, and the tooltip reads exact flows.