When to Use
Use Sankey diagrams when you need to:- Visualize energy or material flows in systems
- Show user journey flows and conversion funnels
- Display budget allocations and fund transfers
- Illustrate supply chain flows and logistics
- Represent data transformations and ETL pipelines
- Show traffic flow and network bandwidth usage
Basic Configuration
A Sankey diagram requires nodes and links (edges) data where each link has a numeric value determining its width.Complete Example
Here’s a comprehensive example showing an energy flow diagram:Key Options
Node Data
Array of node data. From SankeySeries.ts:73-86, 142
Edge Data
Array of link (edge) data. From SankeySeries.ts:88-94, 145
Layout Configuration
Layout orientation. From SankeySeries.ts:116, 313
'horizontal': Nodes flow from left to right'vertical': Nodes flow from top to bottom
Node alignment strategy. From SankeySeries.ts:140, 341
'justify': Spread nodes to justify within the layout'left': Align all nodes to the left'right': Align all nodes to the right
Width of node rectangles in pixels. From SankeySeries.ts:120, 315
Vertical gap between nodes in pixels. From SankeySeries.ts:124, 317
Number of iterations for layout optimization. From SankeySeries.ts:138, 320Higher values may produce better layouts but take longer to compute.
Interaction
Whether nodes can be dragged to adjust positions. From SankeySeries.ts:129, 318
Whether to enable zoom and pan. From SankeySeries.ts:323
Labels
Node label configuration. From SankeySeries.ts:328-332
Edge label configuration. From SankeySeries.ts:150-152, 334-337
Line Style
Style for edge lines. From SankeySeries.ts:63-65, 343-347
Emphasis
What to highlight on hover. From SankeySeries.ts:69
'self': Only the hovered element'adjacency': Connected nodes and edges'trajectory': The complete flow path
Emphasis state styling. From SankeySeries.ts:349-356
Levels
Depth-level specific configurations. From SankeySeries.ts:96-98, 148, 339Each level configuration applies to all nodes at that depth.
Layout Box
Distance from left edge. From SankeySeries.ts:308
Distance from top edge. From SankeySeries.ts:309
Distance from right edge. From SankeySeries.ts:310
Distance from bottom edge. From SankeySeries.ts:311
Advanced Features
Gradient Coloring
SetlineStyle.color: 'gradient' to create a gradient from the source node color to the target node color:
Custom Node Positioning
Usedepth, localX, and localY in node data for manual positioning:
Focus Modes
Different focus modes highlight different parts of the diagram:adjacency: Shows immediate connectionstrajectory: Shows the complete flow path through the network
Best Practices
- Use meaningful node names that clearly identify each stage
- Set appropriate
nodeGapto prevent node overlap - Use
levelsto apply consistent styling to each depth level - Enable
draggableto let users optimize node positions - Set
lineStyle.color: 'gradient'for visually appealing flow visualization - Use
emphasis.focus: 'trajectory'to highlight complete flow paths - Consider
orient: 'vertical'for processes that naturally flow top-to-bottom - Increase
layoutIterationsfor complex diagrams to improve automatic layout - Use
nodeAlign: 'justify'for balanced layouts, or ‘left’/‘right’ for aligned layouts - Show edge labels only when the values are essential (can get cluttered)