Sankey Chart
A Sankey chart recipe - Recharts drawn with Appica UI tokens, for a volume moving between stages.
A Sankey chart shows how a volume splits and merges as it moves from 1 set of stages to the next. Like every chart here it is a recipe: Recharts draws it and the chart layer themes it. Each example below is a complete file to paste and adapt.
Installation
Recharts is the only extra dependency, with react-is at the same version as react:
pnpm add recharts react-isThe examples import the chart layer from @/components/chart. If your project doesn't have it yet, copy it from the Charts page first.
Example
The data is a list of nodes and a list of links between them, where source and target are node indexes. Each source node carries a series color as its fill and its links take the same color, while the outcome nodes stay neutral in --foreground-subtle. Sankey is a chart of its own: it takes no responsive, and Chart sizes it. It also has no entrance animation, so it needs no useChartMotion.
Accessibility
- Pass
aria-labelto the chart with what it shows ("Payment volume by method and outcome"). It becomes the accessible name of the SVG. labelprints every node's name beside it, so nothing depends on color, and the tooltip names the 2 ends of a link.- Keep to 3 colored sources. Color the rest by meaning or leave them neutral.
- Nothing animates under reduced motion.