Sankey component creates flow diagrams where the width of arrows is proportional to flow quantity. It’s ideal for visualizing energy transfers, material flows, cost distributions, or any process with inputs and outputs.
Basic sankey diagram
Sankey requires a specific data structure:
nodes: Array of objects with at least anamepropertylinks: Array of objects withsource,target(node indices), andvalueproperties
Custom node width and padding
Link curvature
linkCurvature ranges from 0 to 1. Default is 0.5.Custom node colors
Custom link colors
Vertical alignment
"justify": Distributes nodes evenly and balances link paths"top": Positions nodes starting from the top edge
Horizontal alignment
"justify": Start nodes align left, end nodes align right"left": All nodes align to the left
Disable node sorting
By default, nodes are sorted vertically. Set
sort={false} to preserve the order from your data.Custom iterations
Event handlers
Event handlers receive three parameters:
item: The node or link datatype: Either'node'or'link'event: The mouse event
With margin
Complex flow example
Common pitfalls
- Data structure: Links must reference nodes by their array index (0-based), not by name or id.
- Node order: The order of nodes in the array affects visualization. Place source nodes before target nodes for best results.
- Responsive sizing: Sankey doesn’t support
responsivemode. Always use fixedwidthandheight. - Missing values: Every link must have a
valueproperty. Missing or zero values may cause rendering issues. - Tooltip event type: Sankey only supports
'item'tooltip event type. - Cyclic flows: Sankey diagrams are designed for acyclic flows (no loops). Cycles in data may produce unexpected results.