Sankey

Weighted flow between nodes across stages.

Import

import { Sankey } from '@matix/charts/sankey';

Usage

Data for Visits, Signup, Bounce, Paid, Churn
SourceTargetValue
Visits:Signup.60.
Visits:Bounce.40.
Signup:Paid.35.
Signup:Churn.25.

Multi-stage flow

Nodes are placed in columns by their longest path from a source, so any acyclic flow — budgets, energy, conversion — lays out automatically.

Data for Oil, Gas, Grid, Homes, Industry, Loss
SourceTargetValue
Oil:Grid.25.
Gas:Grid.35.
Grid:Homes.30.
Grid:Industry.22.
Grid:Loss.8.

API Reference

PropTypeDefaultDescription
nodesreadonly SankeyNode[]—Graph nodes; colors follow order unless colorIndex is set
linksreadonly SankeyLink[]—Directed weighted flows
widthnumber—Controlled layout width; enables deterministic SSR
initialWidthnumber—SSR width hint replaced by client measurement
heightnumber320SVG height in px — width is measured from the container
nodeWidthnumber12Node rectangle thickness in px
nodePaddingnumber12Vertical gap between nodes in a column, px
showLabelsbooleantrueNode labels beside each rect
showTooltipbooleantrueHover tooltip for nodes (throughput) and links (flow)
animatebooleantrueDiagram fades in on mount
formattersChartFormatters—Format node labels and flow values across every surface
labelstring—Accessible name; defaults to the joined node labels
labelsChartLabels—Screen-reader text of the data table and the legend, for translation
showLabelbooleanfalseRender label as a visible title above the plot
sxStyleXStyles—StyleX style override

SankeyNode

FieldTypeDescription
idstringStable identity — links reference this
labelstringNode / tooltip label, falls back to id
colorIndexnumberPalette slot 0–7; defaults to input order
FieldTypeDescription
sourcestringSource node id
targetstringTarget node id
valuenumberFinite positive flow magnitude; invalid links are skipped

Links referencing an unknown node, forming a self-loop, or carrying a non-positive value are dropped. The graph is assumed acyclic.

Accessibility

  • label provides the concise image name. description adds a richer summary through aria-describedby; consumer-owned text or a visible table can be linked with the aria-describedby prop.
  • Up to 20 valid links receive a visually hidden native source/target/value table. accessibleData replaces that table with custom React content; pass null to suppress it. labels translates the table text and the legend name.
  • Node, ribbon, and label marks remain aria-hidden; the chart is one image target and the table carries flow values.
  • The pointer tooltip is supplemental; the table carries values for assistive technology.

Server rendering

Pass width for deterministic server-rendered SVG. Use initialWidth for responsive hydration from a server estimate. Without either prop, the wrapper reserves height before client measurement.