Sankey Chart
A composable sankey diagram for showing how quantities flow between stages, sources, and outcomes.
Overview
Use a sankey diagram when the question is where something goes: which traffic sources lead to signups, how a budget splits into spending, or how energy moves through a system. Each link's width is proportional to its value, and each node's height is the larger of what flows in and out of it. Unlike a funnel, flows can split, merge, and skip columns.
Anatomy
SankeyChart takes one row per link and derives the nodes from the source and target names. Add Nodes to control node width, spacing, and column alignment, Links for link color, opacity, and curvature, Labels for node names and totals, and Tooltip for a node's inflow and outflow or a link's value and share of its source.
A node with its own config entry takes that color. A node without one borrows the color of its largest inflow, so a flow keeps its identity until it reaches a node that defines its own color. Links are tinted by their source at low opacity, and hovering a node or link keeps only its neighbourhood in focus.
Accessibility
When ariaLabel is omitted, the generated name counts the flows and nodes, names the sources, and lists the largest flows. Link width carries the value, and colors only group related flows, so the diagram still reads without color. The tooltip and hover focus are pointer-operated; give people a table of flows when exact values matter.
Installation
Usage
import { SankeyChart, type ChartConfig } from "honestui/charts";<SankeyChart
data={data}
config={chartConfig}
sourceKey="from"
targetKey="to"
valueKey="visitors"
>
<SankeyChart.Labels />
<SankeyChart.Tooltip />
<SankeyChart.Links />
<SankeyChart.Nodes />
</SankeyChart>Links must not form a cycle, and a node cannot link to itself. Self-links and zero values are skipped. Labels on the last column sit inside the diagram so they never run off the edge.
Gradient Links
Gradient links blend from the source color to the target color, which helps when both ends of each flow matter. This example also shows totals next to each label, left-aligns the columns, and passes nodes to fix the node order.
Loading State
Pass isLoading to reserve the layout with a neutral placeholder diagram and the same loading treatment as the other Honest UI charts.