Implementing Syncfusion Angular Sankey
The Sankey component visualizes directional flow and relationships between entities using nodes and links. Perfect for displaying process flows, energy distribution, resource allocation, and hierarchical relationships with proportional link widths representing quantities.
When to Use This Skill
Use the Sankey component when you need to:
- Visualize Flow Data: Display directional flow with proportional link widths representing quantities
- Show Process Steps: Represent multi-stage processes or workflows
- Analyze Resource Allocation: Visualize how resources move through systems
- Compare Categories: Show relationships and distributions between categories
- Display Hierarchies: Render organizational or hierarchical structures with weighted connections
Component Overview
The Sankey diagram consists of:
- Nodes: Represent sources, sinks, and intermediate entities (customizable width, color, labels)
- Links: Represent flow between nodes (width proportional to value, customizable curvature and color)
- Labels: Display node and link information with configurable positioning and styling
- Legend: Optional legend for categorizing nodes
- Tooltips: Contextual information on hover or click
Documentation and Navigation Guide
API Reference
📄 Read: references/api-reference.md
Getting Started
📄 Read: references/getting-started.md
- Installation of
@syncfusion/ej2-angular-charts package
- Angular 19+ standalone component setup
- Basic Sankey initialization and first render
- Module injection (Tooltip, Legend services)
- Initial data binding
- When to use: Start here for setup and first working example
Nodes and Links
📄 Read: references/nodes-and-links.md
- Define node structure (id, label, value)
- Customize node appearance (width, padding, colors, opacity)
- Individual node styling and overrides
- Define link relationships between nodes
- Configure link styling (curvature, opacity, color)
- Node offset and positioning
- When to use: Need to configure diagram structure, customize nodes/links, or control positioning
Appearance and Sizing
📄 Read: references/appearance-and-sizing.md
- Set component dimensions (width, height, responsive sizing)
- Background color and border customization
- Margin control
- Theme application (Material, Bootstrap, Tailwind, etc.)
- Global node and link styles
- When to use: Styling the overall diagram, responsive layouts, or theme integration
Labels, Legends, and Tooltips
📄 Read: references/labels-legends-tooltips.md
- Label positioning and styling for nodes and links
- Legend configuration and positioning (top, bottom, left, right)
- Legend highlighting behavior
- Tooltip templates and content customization
- Interactive element behaviors
- When to use: Adding labels, legends, or tooltips for better context
Customization and Styling
📄 Read: references/customization-and-styling.md
- Element-level customization (per-node, per-link styling)
- Predefined color palettes and mapping
- Data-driven conditional styling
- Custom theme creation
- Category-based styling strategies
- Performance optimization for large diagrams
- When to use: Advanced styling, color mapping, or dynamic appearance changes
Events and Interactions
📄 Read: references/events-and-interactions.md
- Lifecycle events (load, loaded)
- Interaction events (nodeClick, nodeEnter, nodeLeave, linkClick)
- Rendering events for dynamic styling (nodeRendering, linkRendering)
- Export and print events
- Event handling patterns
- When to use: Handle user interactions, trigger custom logic, or respond to diagram lifecycle
Advanced Features
📄 Read: references/advanced-features.md
- Horizontal and vertical orientation
- Right-to-left (RTL) layout support
- Print and export functionality (PNG, JPEG, SVG, PDF)
- Accessibility features (WCAG compliance, screen readers)
- Performance optimization for many nodes/links
- Edge cases and troubleshooting
- When to use: Multi-language support, export requirements, accessibility needs, or performance tuning
Quick Start Example
import { Component, ViewEncapsulation } from '@angular/core';
import { SankeyAllModule } from '@syncfusion/ej2-angular-charts';
@Component({
imports: [SankeyAllModule],
standalone: true,
selector: 'app-sankey-demo',
template: `<ejs-sankey [dataSource]="data" [nodeSettings]="nodeSettings"></ejs-sankey>`,
encapsulation: ViewEncapsulation.None
})
export class SankeyDemoComponent {
data: any[] = [
{ sourceID: 'S1', targetID: 'T1', value: 5 },
{ sourceID: 'S1', targetID: 'T2', value: 3 },
{ sourceID: 'S2', targetID: 'T1', value: 2 }
];
nodeSettings: any = {
width: 20,
padding: 10
};
}
Common Patterns
Pattern 1: Flow Visualization with Categories
// Define nodes with categories for legend grouping
const nodes = [
{ id: 'Power', label: { text: 'Power Plant' }, category: 'Source' },
{ id: 'Grid', label: { text: 'Grid' }, category: 'Intermediary' },
{ id: 'Home', label: { text: 'Households' }, category: 'Sink' }
];
// Links represent flow quantities
const links = [
{ sourceID: 'Power', targetID: 'Grid', value: 100 },
{ sourceID: 'Grid', targetID: 'Home', value: 80 }
];
Pattern 2: Dynamic Styling Based on Values
// Render event handler for value-based coloring INodeRenderingEventArgs) => {
const value = args.node.value || 0;
args.node.color = value > 100 ? '#00A651' : value > 50 ? '#FFB81C' : '#E81B23';
};
Pattern 3: Interactive Highlighting
// Use opacity to emphasize relationships INodeEnterEventArgs) => {
args.node.highlightOpacity = 1;
};
INodeLeaveEventArgs) => {
args.node.highlightOpacity = 0.3;
};
Key Configuration Properties
| Property |
Type |
Purpose |
width |
string |
Component width ('700px', '100%', or '90%') |
height |
string |
Component height ('420px', '450px', or '100%') |
title |
string |
Main title for the diagram |
subTitle |
string |
Subtitle with descriptive text |
orientation |
string |
Flow direction ('Horizontal' or 'Vertical') |
enableRtl |
boolean |
Enable right-to-left layout |
theme |
string |
Built-in theme (Material, Bootstrap, Tailwind, HighContrast, etc.) |
nodeStyle |
Object |
Global node styling (width, padding, opacity, colors) |
linkStyle |
Object |
Global link styling (curvature, opacity, colorType) |
labelSettings |
Object |
Label positioning and visibility |
legendSettings |
Object |
Legend configuration and positioning |
tooltip |
Object |
Tooltip template and visibility settings |
nodes |
Array |
Node definitions (manual property binding) |
links |
Array |
Link definitions (manual property binding) |
Common Use Cases
- Energy Distribution: Show power flow from generation (Solar, Nuclear, Natural Gas) to consumption (Residential, Commercial, Industrial)
- Supply Chain: Visualize product movement through manufacturing → warehouses → distribution centers → retail stores
- Financial Flow: Display money transfers between sources (revenue, investment) → operations → expenses
- Process Workflows: Represent multi-stage processes with branching paths and bottleneck analysis
- User Journeys: Track user movement through application sections (landing → signup → onboarding → features)
- Resource Allocation: Show how budget or resources are distributed across departments or projects
- Hierarchical Structures: Visualize organizational or system hierarchies with weighted relationships
Related Documentation: See implementing-syncfusion-angular-components for other data visualization components.
1---2name: syncfusion-angular-sankey3description: Create and configure Syncfusion Angular Sankey diagrams for flow visualization. Use this when visualizing weighted flows, processes, and hierarchical relationships. Supports node and link styling, legends, tooltips, events, accessibility features, and comprehensive data binding for complex flow diagrams.4---56# Implementing Syncfusion Angular Sankey78The Sankey component visualizes directional flow and relationships between entities using nodes and links. Perfect for displaying process flows, energy distribution, resource allocation, and hierarchical relationships with proportional link widths representing quantities.910## When to Use This Skill1112Use the Sankey component when you need to:13- **Visualize Flow Data:** Display directional flow with proportional link widths representing quantities14- **Show Process Steps:** Represent multi-stage processes or workflows15- **Analyze Resource Allocation:** Visualize how resources move through systems16- **Compare Categories:** Show relationships and distributions between categories17- **Display Hierarchies:** Render organizational or hierarchical structures with weighted connections1819## Component Overview2021The Sankey diagram consists of:22- **Nodes:** Represent sources, sinks, and intermediate entities (customizable width, color, labels)23- **Links:** Represent flow between nodes (width proportional to value, customizable curvature and color)24- **Labels:** Display node and link information with configurable positioning and styling25- **Legend:** Optional legend for categorizing nodes26- **Tooltips:** Contextual information on hover or click2728## Documentation and Navigation Guide2930### API Reference31📄 **Read:** [references/api-reference.md](references/api-reference.md)3233### Getting Started34📄 **Read:** [references/getting-started.md](references/getting-started.md)35- Installation of `@syncfusion/ej2-angular-charts` package36- Angular 19+ standalone component setup37- Basic Sankey initialization and first render38- Module injection (Tooltip, Legend services)39- Initial data binding40- **When to use:** Start here for setup and first working example4142### Nodes and Links43📄 **Read:** [references/nodes-and-links.md](references/nodes-and-links.md)44- Define node structure (id, label, value)45- Customize node appearance (width, padding, colors, opacity)46- Individual node styling and overrides47- Define link relationships between nodes48- Configure link styling (curvature, opacity, color)49- Node offset and positioning50- **When to use:** Need to configure diagram structure, customize nodes/links, or control positioning5152### Appearance and Sizing53📄 **Read:** [references/appearance-and-sizing.md](references/appearance-and-sizing.md)54- Set component dimensions (width, height, responsive sizing)55- Background color and border customization56- Margin control57- Theme application (Material, Bootstrap, Tailwind, etc.)58- Global node and link styles59- **When to use:** Styling the overall diagram, responsive layouts, or theme integration6061### Labels, Legends, and Tooltips62📄 **Read:** [references/labels-legends-tooltips.md](references/labels-legends-tooltips.md)63- Label positioning and styling for nodes and links64- Legend configuration and positioning (top, bottom, left, right)65- Legend highlighting behavior66- Tooltip templates and content customization67- Interactive element behaviors68- **When to use:** Adding labels, legends, or tooltips for better context6970### Customization and Styling71📄 **Read:** [references/customization-and-styling.md](references/customization-and-styling.md)72- Element-level customization (per-node, per-link styling)73- Predefined color palettes and mapping74- Data-driven conditional styling75- Custom theme creation76- Category-based styling strategies77- Performance optimization for large diagrams78- **When to use:** Advanced styling, color mapping, or dynamic appearance changes7980### Events and Interactions81📄 **Read:** [references/events-and-interactions.md](references/events-and-interactions.md)82- Lifecycle events (load, loaded)83- Interaction events (nodeClick, nodeEnter, nodeLeave, linkClick)84- Rendering events for dynamic styling (nodeRendering, linkRendering)85- Export and print events86- Event handling patterns87- **When to use:** Handle user interactions, trigger custom logic, or respond to diagram lifecycle8889### Advanced Features90📄 **Read:** [references/advanced-features.md](references/advanced-features.md)91- Horizontal and vertical orientation92- Right-to-left (RTL) layout support93- Print and export functionality (PNG, JPEG, SVG, PDF)94- Accessibility features (WCAG compliance, screen readers)95- Performance optimization for many nodes/links96- Edge cases and troubleshooting97- **When to use:** Multi-language support, export requirements, accessibility needs, or performance tuning9899## Quick Start Example100101```typescript102import { Component, ViewEncapsulation } from '@angular/core';103import { SankeyAllModule } from '@syncfusion/ej2-angular-charts';104105@Component({106 imports: [SankeyAllModule],107 standalone: true,108 selector: 'app-sankey-demo',109 template: `<ejs-sankey [dataSource]="data" [nodeSettings]="nodeSettings"></ejs-sankey>`,110 encapsulation: ViewEncapsulation.None111})112export class SankeyDemoComponent {113 data: any[] = [114 { sourceID: 'S1', targetID: 'T1', value: 5 },115 { sourceID: 'S1', targetID: 'T2', value: 3 },116 { sourceID: 'S2', targetID: 'T1', value: 2 }117 ];118119 nodeSettings: any = {120 width: 20,121 padding: 10122 };123}124```125126## Common Patterns127128### Pattern 1: Flow Visualization with Categories129```typescript130// Define nodes with categories for legend grouping131const nodes = [132 { id: 'Power', label: { text: 'Power Plant' }, category: 'Source' },133 { id: 'Grid', label: { text: 'Grid' }, category: 'Intermediary' },134 { id: 'Home', label: { text: 'Households' }, category: 'Sink' }135];136137// Links represent flow quantities138const links = [139 { sourceID: 'Power', targetID: 'Grid', value: 100 },140 { sourceID: 'Grid', targetID: 'Home', value: 80 }141];142```143144### Pattern 2: Dynamic Styling Based on Values145```typescript146// Render event handler for value-based coloring147onNodeRendering = (args: INodeRenderingEventArgs) => {148 const value = args.node.value || 0;149 args.node.color = value > 100 ? '#00A651' : value > 50 ? '#FFB81C' : '#E81B23';150};151```152153### Pattern 3: Interactive Highlighting154```typescript155// Use opacity to emphasize relationships156onNodeEnter = (args: INodeEnterEventArgs) => {157 args.node.highlightOpacity = 1;158};159160onNodeLeave = (args: INodeLeaveEventArgs) => {161 args.node.highlightOpacity = 0.3;162};163```164165## Key Configuration Properties166167| Property | Type | Purpose |168|----------|------|---------|169| `width` | string | Component width ('700px', '100%', or '90%') |170| `height` | string | Component height ('420px', '450px', or '100%') |171| `title` | string | Main title for the diagram |172| `subTitle` | string | Subtitle with descriptive text |173| `orientation` | string | Flow direction ('Horizontal' or 'Vertical') |174| `enableRtl` | boolean | Enable right-to-left layout |175| `theme` | string | Built-in theme (Material, Bootstrap, Tailwind, HighContrast, etc.) |176| `nodeStyle` | Object | Global node styling (width, padding, opacity, colors) |177| `linkStyle` | Object | Global link styling (curvature, opacity, colorType) |178| `labelSettings` | Object | Label positioning and visibility |179| `legendSettings` | Object | Legend configuration and positioning |180| `tooltip` | Object | Tooltip template and visibility settings |181| `nodes` | Array | Node definitions (manual property binding) |182| `links` | Array | Link definitions (manual property binding) |183184## Common Use Cases1851861. **Energy Distribution:** Show power flow from generation (Solar, Nuclear, Natural Gas) to consumption (Residential, Commercial, Industrial)1872. **Supply Chain:** Visualize product movement through manufacturing → warehouses → distribution centers → retail stores1883. **Financial Flow:** Display money transfers between sources (revenue, investment) → operations → expenses1894. **Process Workflows:** Represent multi-stage processes with branching paths and bottleneck analysis1905. **User Journeys:** Track user movement through application sections (landing → signup → onboarding → features)1916. **Resource Allocation:** Show how budget or resources are distributed across departments or projects1927. **Hierarchical Structures:** Visualize organizational or system hierarchies with weighted relationships193194--- 195**Related Documentation:** See [implementing-syncfusion-angular-components](../) for other data visualization components.