Sankey Diagram

How an amount flows between stages — traffic sources into pages and outcomes, a budget into departments. Links are as wide as their value. Drawn as SVG by the component, rendered on the server and themed by the design tokens.

Part of @tectra-ng/charts (npm install @tectra-ng/charts, also included in tectra-ng).

Features10APIThemingAccessibility

Basic

Nodes stand in columns by stage and links are as wide as their value. Hover a node to light its flows, or a link for its value and share of the source.

Arrow keys move between values
Visitors from source to outcome. Sankey diagram, 12 flows
CategoryValue
Search → Home page4.2K
Ads → Home page2.6K
Ads → Pricing1.4K
Social → Home page1.8K
Email → Pricing900
Home page → Pricing3.1K
Home page → Docs2.2K
Home page → Left3.3K
Pricing → Signed up2.3K
Pricing → Left3.1K
Docs → Signed up700
Docs → Left1.5K

Budget

Without nodes the ids are the names. A node can collect flows from many sources — here every department pays salaries.

Arrow keys move between values
Budget by department. Sankey diagram, 9 flows
CategoryValue
Budget → Engineering4.2M
Budget → Sales1.9M
Budget → Operations1.1M
Engineering → Salaries3.3M
Engineering → Cloud900K
Sales → Salaries1.2M
Sales → Events700K
Operations → Office650K
Operations → Salaries450K

Align

align="left" puts every node right after its sources, so "Solved" stands next to triage instead of in the last column. showValues turns the numbers off.

Arrow keys move between values
Support tickets. Sankey diagram, 6 flows
CategoryValue
Email → Triage320
Chat → Triage540
Triage → Solved610
Triage → Engineering250
Engineering → Fixed190
Engineering → Won't fix60

Events

nodeClick reports a node with its in and out totals, linkClick a flow with its value.

Arrow keys move between values
Leads by stage. Sankey diagram, 4 flows
CategoryValue
Leads → Qualified420
Leads → Lost380
Qualified → Won160
Qualified → Lost260

Click a node or a link.

Loading and empty

loading keeps the size with a skeleton; empty links show "No data".

No data

Live

New links redraw in place — nodes and flows slide to their new size.

Arrow keys move between values
Monthly flows. Sankey diagram, 4 flows
CategoryValue
Web → Trial20
App → Trial37
Trial → Paid49
Trial → Churned61

Accessibility

Tab to the chart: the arrow keys walk the nodes column by column, each one lights its flows and is announced with its in and out totals. Screen readers also get a summary and a hidden table of every flow.

Arrow keys move between values
Website visitors. Sankey diagram, 12 flows
CategoryValue
Search → Home page4.2K
Ads → Home page2.6K
Ads → Pricing1.4K
Social → Home page1.8K
Email → Pricing900
Home page → Pricing3.1K
Home page → Docs2.2K
Home page → Left3.3K
Pricing → Signed up2.3K
Pricing → Left3.1K
Docs → Signed up700
Docs → Left1.5K

Design tokens

dt sets the node width, the gap between nodes, their radius, how strongly the links take the node colour, the edge between them and the labels of one chart.

Arrow keys move between values
Energy use. Sankey diagram, 5 flows
CategoryValue
Solar → Grid30
Wind → Grid45
Gas → Grid25
Grid → Homes40
Grid → Industry60

Pass through

pt reaches the parts — node, link, label, plot, tooltip and more.

Arrow keys move between values
Order fulfilment. Sankey diagram, 4 flows
CategoryValue
Orders → Shipped820
Orders → Cancelled90
Shipped → Delivered790
Shipped → Returned30

Unstyled

unstyled removes the tectra styles: no tokens, no motion — the layout, the colours, the tooltip and the keyboard stay, ready for your own CSS.

Arrow keys move between values
Unstyled chart. Sankey diagram, 3 flows
CategoryValue
A → C5
B → C3
C → D8