Implementing Syncfusion Blazor Sankey Diagram
NuGet: Syncfusion.Blazor.Sankey + Syncfusion.Blazor.Themes
Namespace: Syncfusion.Blazor.Sankey
A comprehensive skill for implementing the Syncfusion Blazor Sankey Diagram component. The Sankey diagram is a powerful visualization tool for displaying flows and relationships between categories, showing the magnitude and direction of flows using proportionally-sized links.
When to Use This Skill
Use this skill when you need to:
- Visualize flows and relationships between different categories or stages
- Display energy or resource flows in systems (electricity, water, materials)
- Show data movements between entities (website traffic, user journeys, data pipelines)
- Illustrate budget or financial flows (income/expenses, resource allocation)
- Map supply chain or logistics flows (product movement, distribution)
- Create process flow diagrams with quantifiable magnitudes
- Analyze network flows (data transfer, communication patterns)
- Display conversion funnels with drop-off visualization
- Implement the
SfSankey Blazor component
- Work with flow data structures (nodes and links)
- Customize Sankey diagram appearance and behavior
- Handle interactive events for flow exploration
- Export or print flow diagrams
Component Overview
What is a Sankey Diagram?
A Sankey diagram is a flow diagram where the width of arrows or connections is proportional to the flow magnitude. It consists of:
- Nodes: Entities, categories, or stages in the flow (e.g., energy sources, process steps)
- Links: Connections between nodes showing flow direction and magnitude
- Flow Width: Visual representation of quantity/magnitude (wider = larger flow)
Key Features
- Data-driven visualization with nodes and links collections
- Automatic layout with configurable orientation (horizontal/vertical)
- Rich customization for nodes, links, labels, and legends
- Interactive events for clicks, hovers, and rendering customization
- Tooltips showing flow details on hover
- Print and export functionality (PNG, JPEG, SVG, PDF)
- Accessibility compliant with WCAG 2.2 standards
- Responsive design with dynamic resizing
Documentation and Navigation Guide
Getting Started
📄 Read: references/getting-started.md
When to read: First-time setup, installation, project configuration
Contains:
- NuGet package installation (Syncfusion.Blazor.Sankey)
- Service registration and namespace imports
- CSS theme and script references
- Basic Sankey diagram implementation
- Complete minimal working example
- Setup troubleshooting
Data Binding
📄 Read: references/data-binding.md
When to read: Setting up data structure, binding nodes and links, API integration
Contains:
- Understanding SankeyDataNode and SankeyDataLink models
- Creating nodes and links collections
- Binding data to the Sankey component
- REST API integration patterns
- JSON data structure examples
- Dynamic data updates
Nodes Configuration
📄 Read: references/nodes.md
When to read: Customizing node appearance, styling, properties
Contains:
- Node fundamentals and structure
- Node ID and label configuration
- Node styling with SankeyNodeSettings
- Color, width, and padding properties
- Node positioning and layout
- Complete node examples
Links Configuration
📄 Read: references/links.md
When to read: Configuring flow connections, link styling, magnitude representation
Contains:
- Link fundamentals and flow representation
- SourceId, TargetId, and Value properties
- Link styling with SankeyLinkSettings
- Color, opacity, and stroke properties
- Flow direction and magnitude
- Multiple path flow examples
Labels Customization
📄 Read: references/labels.md
When to read: Customizing node labels, text formatting
Contains:
- Label configuration and positioning
- Font properties (size, weight, family, color)
- Text formatting and truncation
- Label visibility controls
- Custom label examples
Legends Configuration
📄 Read: references/legends.md
When to read: Adding and customizing diagram legends
Contains:
- Legend configuration with SankeyLegendSettings
- Visibility and positioning options
- Legend item customization
- Shape and color mapping
- Interactive legend behavior
- LegendItemRendering event
Tooltips
📄 Read: references/tooltips.md
When to read: Adding interactive tooltips, customizing tooltip content
Contains:
- Tooltip configuration and triggers
- Custom tooltip templates
- Node and link tooltip differentiation
- TooltipRendering event
- Formatting tooltip content
- Styling examples
API Reference
📄 Read: references/api-reference.md
When to read: Looking up component properties, events, methods, and enums
Contains:
- Complete SfSankey component API documentation
- All properties with types and defaults
- All 16 events with event arguments
- All public methods (Export, Print, Refresh)
- Data model classes (SankeyDataNode, SankeyDataLink, SankeyDataLabel)
- Settings components (Node, Link, Label, Legend, Tooltip)
- Enums and event arguments
- Full component hierarchy
- Complete working examples
Customization
📄 Read: references/customization.md
When to read: Advanced styling, layout options, themes, RTL support
Contains:
- Background styling (color and image)
- Diagram dimensions and sizing
- Layout orientation (horizontal/vertical)
- RTL (Right-to-Left) support
- Theme integration
- Custom CSS classes
- Responsive design patterns
Events and Interactivity
📄 Read: references/events.md
When to read: Handling user interactions, customizing rendering, responding to changes
Contains:
- Complete event reference (16 events)
- Rendering events (NodeRendering, LinkRendering, LabelRendering)
- Interaction events (NodeClick, LinkClick)
- Hover events (NodeEnter/Leave, LinkEnter/Leave)
- Lifecycle events (Created, SizeChanged)
- Export events (PrintCompleted, ExportCompleted)
- Event argument structures and examples
Print and Export
📄 Read: references/print-export.md
When to read: Exporting diagrams to images/PDF, printing functionality
Contains:
- Printing Sankey diagrams
- Export formats (PNG, JPEG, SVG, PDF)
- Export method configuration
- File naming and quality settings
- Print/export events
- Complete working examples
Quick Start Example
Here's a minimal example showing energy source flow to energy types and end-use sectors:
@page "/sankey-demo"
@using Syncfusion.Blazor.Sankey
<SfSankey Width="100%" Height="600px" Nodes="@Nodes" Links="@Links">
<SankeyNodeSettings Width="20" Padding="20"></SankeyNodeSettings>
<SankeyLinkSettings Opacity="0.4"></SankeyLinkSettings>
</SfSankey>
@code {
public List<SankeyDataNode> Nodes = new List<SankeyDataNode>();
public List<SankeyDataLink> Links = new List<SankeyDataLink>();
protected override void OnInitialized()
{
// Define nodes
Nodes = new List<SankeyDataNode>()
{
new SankeyDataNode() { Id = "Solar", Label = new SankeyDataLabel() { Text = "Solar" } },
new SankeyDataNode() { Id = "Wind", Label = new SankeyDataLabel() { Text = "Wind" } },
new SankeyDataNode() { Id = "Hydro", Label = new SankeyDataLabel() { Text = "Hydro" } },
new SankeyDataNode() { Id = "Electricity", Label = new SankeyDataLabel() { Text = "Electricity" } },
new SankeyDataNode() { Id = "Heat", Label = new SankeyDataLabel() { Text = "Heat" } },
new SankeyDataNode() { Id = "Residential", Label = new SankeyDataLabel() { Text = "Residential" } },
new SankeyDataNode() { Id = "Commercial", Label = new SankeyDataLabel() { Text = "Commercial" } },
new SankeyDataNode() { Id = "Industrial", Label = new SankeyDataLabel() { Text = "Industrial" } }
};
// Define links (flows)
Links = new List<SankeyDataLink>()
{
new SankeyDataLink() { SourceId = "Solar", TargetId = "Electricity", Value = 30 },
new SankeyDataLink() { SourceId = "Wind", TargetId = "Electricity", Value = 45 },
new SankeyDataLink() { SourceId = "Hydro", TargetId = "Electricity", Value = 25 },
new SankeyDataLink() { SourceId = "Solar", TargetId = "Heat", Value = 15 },
new SankeyDataLink() { SourceId = "Electricity", TargetId = "Residential", Value = 35 },
new SankeyDataLink() { SourceId = "Electricity", TargetId = "Commercial", Value = 30 },
new SankeyDataLink() { SourceId = "Electricity", TargetId = "Industrial", Value = 35 },
new SankeyDataLink() { SourceId = "Heat", TargetId = "Residential", Value = 10 },
new SankeyDataLink() { SourceId = "Heat", TargetId = "Commercial", Value = 5 }
};
}
}
Common Patterns
Pattern 1: Simple Flow Diagram
<SfSankey Nodes="@Nodes" Links="@Links" Width="800px" Height="400px">
</SfSankey>
Pattern 2: Styled Sankey with Custom Colors
<SfSankey Nodes="@Nodes" Links="@Links" BackgroundColor="#f5f5f5">
<SankeyNodeSettings Color="#2e7d32" Width="15" Padding="25"></SankeyNodeSettings>
<SankeyLinkSettings Color="#1976d2" Opacity="0.3"></SankeyLinkSettings>
<SankeyLabelSettings Color="#000000" FontSize="14px" FontWeight="500"></SankeyLabelSettings>
</SfSankey>
Pattern 3: Interactive Sankey with Events
<SfSankey Nodes="@Nodes" Links="@Links" NodeClick="OnNodeClick" LinkClick="OnLinkClick">
<SankeyTooltipSettings Visible="true"></SankeyTooltipSettings>
</SfSankey>
@code {
private void OnNodeClick(NodeClickEventArgs args)
{
Console.WriteLine($"Node clicked: {args.Node.Id}");
}
private void OnLinkClick(LinkClickEventArgs args)
{
Console.WriteLine($"Link clicked: {args.Link.SourceId} -> {args.Link.TargetId}");
}
}
Pattern 4: Vertical Orientation
<SfSankey Nodes="@Nodes" Links="@Links" Orientation="SankeyOrientation.Vertical">
<SankeyNodeSettings Width="30" Padding="15"></SankeyNodeSettings>
</SfSankey>
Pattern 5: With Legend
<SfSankey Nodes="@Nodes" Links="@Links">
<SankeyLegendSettings Visible="true" Position="LegendPosition.Bottom"></SankeyLegendSettings>
</SfSankey>
Complete API Properties Reference
SfSankey Component Properties
Data Properties
| Property |
Type |
Default |
Description |
Nodes |
List<SankeyDataNode> |
null |
Collection of nodes (entities/categories) |
Links |
List<SankeyDataLink> |
null |
Collection of links (flows between nodes) |
Layout & Sizing Properties
| Property |
Type |
Default |
Description |
Width |
string |
"100%" |
Diagram width (pixels or percentage) |
Height |
string |
"100%" |
Diagram height (pixels or percentage) |
Orientation |
SankeyOrientation |
Auto |
Layout direction (Auto/Horizontal/Vertical) |
EnableAutoLayout |
bool |
true |
Enable/disable automatic layout |
Styling Properties
| Property |
Type |
Default |
Description |
BackgroundColor |
string |
Theme default |
Background color |
BackgroundImage |
string |
"" |
Background image URL |
BorderColor |
string |
null |
Border color |
BorderWidth |
double |
1 |
Border width in pixels |
Theme |
Theme |
Fluent2 |
Chart theme |
CssClass |
string |
"" |
Custom CSS class |
Title & Content Properties
| Property |
Type |
Default |
Description |
Title |
string |
"" |
Main title text |
SubTitle |
string |
"" |
Subtitle text |
LinkCurvature |
double |
1 |
Link curve intensity (0-1) |
Animation Properties
| Property |
Type |
Default |
Description |
EnableAnimation |
bool |
true |
Enable/disable animations |
AnimationDuration |
double |
2000 |
Animation duration (ms) |
AnimationDelay |
double |
0 |
Animation delay (ms) |
Accessibility & Interaction Properties
| Property |
Type |
Default |
Description |
EnableRTL |
bool |
false |
Enable right-to-left layout |
TabIndex |
double |
0 |
Keyboard tab index |
AccessibilityDescription |
string |
"" |
Accessibility description |
ID |
string |
Auto-generated |
Component ID |
Events Reference (16 Total Events)
Rendering Events
NodeRendering - SankeyNodeRenderEventArgs - Fired when a node is rendered
LinkRendering - SankeyLinkRenderEventArgs - Fired when a link is rendered
LabelRendering - SankeyLabelRenderEventArgs - Fired when a label is rendered
LegendItemRendering - SankeyLegendRenderEventArgs - Fired before legend item renders
Mouse Interaction Events
NodeClick - SankeyNodeEventArgs - Fired when node is clicked
LinkClick - SankeyLinkEventArgs - Fired when link is clicked
NodeEnter - SankeyNodeEventArgs - Fired when mouse enters node
NodeLeave - SankeyNodeEventArgs - Fired when mouse leaves node
LinkEnter - SankeyLinkEventArgs - Fired when mouse enters link
LinkLeave - SankeyLinkEventArgs - Fired when mouse leaves link
UI Events
TooltipRendering - SankeyTooltipRenderEventArgs - Fired when tooltip renders
LegendItemHover - SankeyLegendItemHoverEventArgs - Fired on legend hover
Lifecycle Events
Created - Action - Fired when component is created
SizeChanged - SankeySizeChangedEventArgs - Fired when component size changes
Export/Print Events
PrintCompleted - Action - Fired when print completes
ExportCompleted - SankeyExportedEventArgs - Fired when export completes
Public Methods
| Method |
Parameters |
Returns |
Description |
ExportAsync |
type (SankeyExportType), fileName, orientation?, allowDownload?, isBase64? |
Task |
Export to PNG/JPEG/SVG/PDF |
PrintAsync |
elementRef? |
Task |
Print the diagram |
RefreshAsync |
None |
Task |
Re-render component |
Settings Objects
- SankeyNodeSettings: Node appearance (Width, Padding, Alignment, Color, Offset)
- SankeyLinkSettings: Link appearance (Color, Opacity, HighlightOpacity, InactiveOpacity, ColorType)
- SankeyLabelSettings: Label styling (Visible, FontSize, FontFamily, FontWeight, Color, Padding)
- SankeyMargin: Chart margins (Left, Right, Top, Bottom)
- SankeyTitleStyle: Title styling (FontSize, FontFamily, FontWeight, FontStyle, Color)
- SankeySubtitleStyle: Subtitle styling (FontSize, FontFamily, FontWeight, FontStyle, Color)
- SankeyLegendSettings: Legend configuration (Visible, Position, Height, Width)
- SankeyTooltipSettings: Tooltip configuration (Enable, Fill, Opacity)
Data Models
| Model |
Key Properties |
Description |
| SankeyDataNode |
Id, Label (SankeyDataLabel), Color, Width |
Represents a node |
| SankeyDataLabel |
Text |
Node label text |
| SankeyDataLink |
SourceId, TargetId, Value, Color, Opacity |
Represents a link/connection |
Enums
| Enum |
Values |
Description |
| SankeyOrientation |
Auto, Horizontal, Vertical |
Layout direction |
| SankeyNodeAlign |
None, Left, Center, Right |
Node alignment |
| SankeyColorType |
Static, Source |
Color mapping type |
| SankeyLegendPosition |
Top, Bottom, Left, Right |
Legend position |
| SankeyExportType |
PNG, JPEG, SVG, PDF |
Export format |
| Theme |
Bootstrap5, Fluent2, Material, Tailwind, Fabric, etc. |
Chart theme |
Common Use Cases
Use Case 1: Energy Flow Visualization
Visualize energy sources flowing to energy types and then to end-use sectors (residential, commercial, industrial).
Use Case 2: Website Traffic Analysis
Show user traffic flow from entry points (search, social, direct) through pages to conversion goals.
Use Case 3: Budget Allocation
Display budget flows from income sources through categories to final expenses.
Use Case 4: Supply Chain Flow
Illustrate product movement from suppliers through manufacturing to distribution channels.
Use Case 5: User Journey Mapping
Map user flow through application states, showing drop-offs and conversions at each stage.
Use Case 6: Data Pipeline Visualization
Show data flow through processing stages in ETL pipelines or data transformation workflows.
Data Structure Requirements
Nodes
Each node must have:
- Unique
Id (string)
Label with Text property
Links
Each link must have:
SourceId matching a node Id
TargetId matching a node Id
Value representing flow magnitude (numeric)
Validation Tips
- Ensure all link SourceId and TargetId reference existing node Ids
- Values should be positive numbers
- Avoid circular flows (node A → B → A) for clarity
- Node Ids are case-sensitive
Troubleshooting Quick Tips
Diagram not showing:
- Verify Nodes and Links are properly initialized
- Check that SfSankey has Width and Height set
- Ensure Syncfusion services are registered in Program.cs
Links not appearing:
- Confirm SourceId and TargetId match existing node Ids exactly
- Check that Value is greater than 0
- Verify Links collection is bound to component
Styling not applying:
- Ensure theme CSS is referenced in App.razor or layout
- Check for conflicting CSS styles
- Verify color format is valid (hex, rgb, named color)
Events not firing:
- Confirm event handler method signature matches event args type
- Check that event is properly bound in component markup
- Verify component interactivity mode for .NET 8+ projects
Next Steps
For detailed implementation of specific features, refer to the reference files listed in the Navigation Guide above. Each reference provides complete, self-contained documentation with examples and best practices.
Resources
Documentation & References
Community & Support
1---2name: syncfusion-blazor-sankey3description: Comprehensive guide for implementing Syncfusion Blazor Sankey Diagram (SfSankey) component for flow visualization in Blazor applications. Use this when working with Sankey diagrams, flow visualization, or process flows. This skill covers node and link configuration, data binding, flow magnitude representation, and diagram customization. Ideal for visualizing energy flows, supply chain relationships, user journey maps, traffic analysis, and any scenario involving flows between categories or stages.4---5
6# Implementing Syncfusion Blazor Sankey Diagram
7
8**NuGet:** `Syncfusion.Blazor.Sankey` + `Syncfusion.Blazor.Themes`
9**Namespace:** `Syncfusion.Blazor.Sankey`
10
11A comprehensive skill for implementing the Syncfusion Blazor Sankey Diagram component. The Sankey diagram is a powerful visualization tool for displaying flows and relationships between categories, showing the magnitude and direction of flows using proportionally-sized links.
12
13## When to Use This Skill
14
15Use this skill when you need to:
16- **Visualize flows and relationships** between different categories or stages
17- **Display energy or resource flows** in systems (electricity, water, materials)
18- **Show data movements** between entities (website traffic, user journeys, data pipelines)
19- **Illustrate budget or financial flows** (income/expenses, resource allocation)
20- **Map supply chain or logistics** flows (product movement, distribution)
21- **Create process flow diagrams** with quantifiable magnitudes
22- **Analyze network flows** (data transfer, communication patterns)
23- **Display conversion funnels** with drop-off visualization
24- Implement the `SfSankey` Blazor component
25- Work with flow data structures (nodes and links)
26- Customize Sankey diagram appearance and behavior
27- Handle interactive events for flow exploration
28- Export or print flow diagrams
29
30## Component Overview
31
32### What is a Sankey Diagram?
33
34A Sankey diagram is a flow diagram where the width of arrows or connections is proportional to the flow magnitude. It consists of:
35
36- **Nodes**: Entities, categories, or stages in the flow (e.g., energy sources, process steps)
37- **Links**: Connections between nodes showing flow direction and magnitude
38- **Flow Width**: Visual representation of quantity/magnitude (wider = larger flow)
39
40### Key Features
41
42- **Data-driven visualization** with nodes and links collections
43- **Automatic layout** with configurable orientation (horizontal/vertical)
44- **Rich customization** for nodes, links, labels, and legends
45- **Interactive events** for clicks, hovers, and rendering customization
46- **Tooltips** showing flow details on hover
47- **Print and export** functionality (PNG, JPEG, SVG, PDF)
48- **Accessibility** compliant with WCAG 2.2 standards
49- **Responsive design** with dynamic resizing
50
51## Documentation and Navigation Guide
52
53### Getting Started
54📄 **Read:** [references/getting-started.md](references/getting-started.md)
55**When to read:** First-time setup, installation, project configuration
56**Contains:**
57- NuGet package installation (Syncfusion.Blazor.Sankey)
58- Service registration and namespace imports
59- CSS theme and script references
60- Basic Sankey diagram implementation
61- Complete minimal working example
62- Setup troubleshooting
63
64### Data Binding
65📄 **Read:** [references/data-binding.md](references/data-binding.md)
66**When to read:** Setting up data structure, binding nodes and links, API integration
67**Contains:**
68- Understanding SankeyDataNode and SankeyDataLink models
69- Creating nodes and links collections
70- Binding data to the Sankey component
71- REST API integration patterns
72- JSON data structure examples
73- Dynamic data updates
74
75### Nodes Configuration
76📄 **Read:** [references/nodes.md](references/nodes.md)
77**When to read:** Customizing node appearance, styling, properties
78**Contains:**
79- Node fundamentals and structure
80- Node ID and label configuration
81- Node styling with SankeyNodeSettings
82- Color, width, and padding properties
83- Node positioning and layout
84- Complete node examples
85
86### Links Configuration
87📄 **Read:** [references/links.md](references/links.md)
88**When to read:** Configuring flow connections, link styling, magnitude representation
89**Contains:**
90- Link fundamentals and flow representation
91- SourceId, TargetId, and Value properties
92- Link styling with SankeyLinkSettings
93- Color, opacity, and stroke properties
94- Flow direction and magnitude
95- Multiple path flow examples
96
97### Labels Customization
98📄 **Read:** [references/labels.md](references/labels.md)
99**When to read:** Customizing node labels, text formatting
100**Contains:**
101- Label configuration and positioning
102- Font properties (size, weight, family, color)
103- Text formatting and truncation
104- Label visibility controls
105- Custom label examples
106
107### Legends Configuration
108📄 **Read:** [references/legends.md](references/legends.md)
109**When to read:** Adding and customizing diagram legends
110**Contains:**
111- Legend configuration with SankeyLegendSettings
112- Visibility and positioning options
113- Legend item customization
114- Shape and color mapping
115- Interactive legend behavior
116- LegendItemRendering event
117
118### Tooltips
119📄 **Read:** [references/tooltips.md](references/tooltips.md)
120**When to read:** Adding interactive tooltips, customizing tooltip content
121**Contains:**
122- Tooltip configuration and triggers
123- Custom tooltip templates
124- Node and link tooltip differentiation
125- TooltipRendering event
126- Formatting tooltip content
127- Styling examples
128
129### API Reference
130📄 **Read:** [references/api-reference.md](references/api-reference.md)
131**When to read:** Looking up component properties, events, methods, and enums
132**Contains:**
133- Complete SfSankey component API documentation
134- All properties with types and defaults
135- All 16 events with event arguments
136- All public methods (Export, Print, Refresh)
137- Data model classes (SankeyDataNode, SankeyDataLink, SankeyDataLabel)
138- Settings components (Node, Link, Label, Legend, Tooltip)
139- Enums and event arguments
140- Full component hierarchy
141- Complete working examples
142
143### Customization
144📄 **Read:** [references/customization.md](references/customization.md)
145**When to read:** Advanced styling, layout options, themes, RTL support
146**Contains:**
147- Background styling (color and image)
148- Diagram dimensions and sizing
149- Layout orientation (horizontal/vertical)
150- RTL (Right-to-Left) support
151- Theme integration
152- Custom CSS classes
153- Responsive design patterns
154
155### Events and Interactivity
156📄 **Read:** [references/events.md](references/events.md)
157**When to read:** Handling user interactions, customizing rendering, responding to changes
158**Contains:**
159- Complete event reference (16 events)
160- Rendering events (NodeRendering, LinkRendering, LabelRendering)
161- Interaction events (NodeClick, LinkClick)
162- Hover events (NodeEnter/Leave, LinkEnter/Leave)
163- Lifecycle events (Created, SizeChanged)
164- Export events (PrintCompleted, ExportCompleted)
165- Event argument structures and examples
166
167### Print and Export
168📄 **Read:** [references/print-export.md](references/print-export.md)
169**When to read:** Exporting diagrams to images/PDF, printing functionality
170**Contains:**
171- Printing Sankey diagrams
172- Export formats (PNG, JPEG, SVG, PDF)
173- Export method configuration
174- File naming and quality settings
175- Print/export events
176- Complete working examples
177
178## Quick Start Example
179
180Here's a minimal example showing energy source flow to energy types and end-use sectors:
181
182```razor
183@page "/sankey-demo"
184@using Syncfusion.Blazor.Sankey
185
186<SfSankey Width="100%" Height="600px" Nodes="@Nodes" Links="@Links">
187 <SankeyNodeSettings Width="20" Padding="20"></SankeyNodeSettings>
188 <SankeyLinkSettings Opacity="0.4"></SankeyLinkSettings>
189</SfSankey>
190
191@code {
192 public List<SankeyDataNode> Nodes = new List<SankeyDataNode>();
193 public List<SankeyDataLink> Links = new List<SankeyDataLink>();
194
195 protected override void OnInitialized()
196 {
197 // Define nodes
198 Nodes = new List<SankeyDataNode>()
199 {
200 new SankeyDataNode() { Id = "Solar", Label = new SankeyDataLabel() { Text = "Solar" } },
201 new SankeyDataNode() { Id = "Wind", Label = new SankeyDataLabel() { Text = "Wind" } },
202 new SankeyDataNode() { Id = "Hydro", Label = new SankeyDataLabel() { Text = "Hydro" } },
203 new SankeyDataNode() { Id = "Electricity", Label = new SankeyDataLabel() { Text = "Electricity" } },
204 new SankeyDataNode() { Id = "Heat", Label = new SankeyDataLabel() { Text = "Heat" } },
205 new SankeyDataNode() { Id = "Residential", Label = new SankeyDataLabel() { Text = "Residential" } },
206 new SankeyDataNode() { Id = "Commercial", Label = new SankeyDataLabel() { Text = "Commercial" } },
207 new SankeyDataNode() { Id = "Industrial", Label = new SankeyDataLabel() { Text = "Industrial" } }
208 };
209
210 // Define links (flows)
211 Links = new List<SankeyDataLink>()
212 {
213 new SankeyDataLink() { SourceId = "Solar", TargetId = "Electricity", Value = 30 },
214 new SankeyDataLink() { SourceId = "Wind", TargetId = "Electricity", Value = 45 },
215 new SankeyDataLink() { SourceId = "Hydro", TargetId = "Electricity", Value = 25 },
216 new SankeyDataLink() { SourceId = "Solar", TargetId = "Heat", Value = 15 },
217 new SankeyDataLink() { SourceId = "Electricity", TargetId = "Residential", Value = 35 },
218 new SankeyDataLink() { SourceId = "Electricity", TargetId = "Commercial", Value = 30 },
219 new SankeyDataLink() { SourceId = "Electricity", TargetId = "Industrial", Value = 35 },
220 new SankeyDataLink() { SourceId = "Heat", TargetId = "Residential", Value = 10 },
221 new SankeyDataLink() { SourceId = "Heat", TargetId = "Commercial", Value = 5 }
222 };
223 }
224}
225```
226
227## Common Patterns
228
229### Pattern 1: Simple Flow Diagram
230```razor
231<SfSankey Nodes="@Nodes" Links="@Links" Width="800px" Height="400px">
232</SfSankey>
233```
234
235### Pattern 2: Styled Sankey with Custom Colors
236```razor
237<SfSankey Nodes="@Nodes" Links="@Links" BackgroundColor="#f5f5f5">
238 <SankeyNodeSettings Color="#2e7d32" Width="15" Padding="25"></SankeyNodeSettings>
239 <SankeyLinkSettings Color="#1976d2" Opacity="0.3"></SankeyLinkSettings>
240 <SankeyLabelSettings Color="#000000" FontSize="14px" FontWeight="500"></SankeyLabelSettings>
241</SfSankey>
242```
243
244### Pattern 3: Interactive Sankey with Events
245```razor
246<SfSankey Nodes="@Nodes" Links="@Links" NodeClick="OnNodeClick" LinkClick="OnLinkClick">
247 <SankeyTooltipSettings Visible="true"></SankeyTooltipSettings>
248</SfSankey>
249
250@code {
251 private void OnNodeClick(NodeClickEventArgs args)
252 {
253 Console.WriteLine($"Node clicked: {args.Node.Id}");
254 }
255
256 private void OnLinkClick(LinkClickEventArgs args)
257 {
258 Console.WriteLine($"Link clicked: {args.Link.SourceId} -> {args.Link.TargetId}");
259 }
260}
261```
262
263### Pattern 4: Vertical Orientation
264```razor
265<SfSankey Nodes="@Nodes" Links="@Links" Orientation="SankeyOrientation.Vertical">
266 <SankeyNodeSettings Width="30" Padding="15"></SankeyNodeSettings>
267</SfSankey>
268```
269
270### Pattern 5: With Legend
271```razor
272<SfSankey Nodes="@Nodes" Links="@Links">
273 <SankeyLegendSettings Visible="true" Position="LegendPosition.Bottom"></SankeyLegendSettings>
274</SfSankey>
275```
276
277## Complete API Properties Reference
278
279### SfSankey Component Properties
280
281#### Data Properties
282| Property | Type | Default | Description |
283|----------|------|---------|-------------|
284| `Nodes` | `List<SankeyDataNode>` | null | Collection of nodes (entities/categories) |
285| `Links` | `List<SankeyDataLink>` | null | Collection of links (flows between nodes) |
286
287#### Layout & Sizing Properties
288| Property | Type | Default | Description |
289|----------|------|---------|-------------|
290| `Width` | `string` | "100%" | Diagram width (pixels or percentage) |
291| `Height` | `string` | "100%" | Diagram height (pixels or percentage) |
292| `Orientation` | `SankeyOrientation` | Auto | Layout direction (Auto/Horizontal/Vertical) |
293| `EnableAutoLayout` | `bool` | true | Enable/disable automatic layout |
294
295#### Styling Properties
296| Property | Type | Default | Description |
297|----------|------|---------|-------------|
298| `BackgroundColor` | `string` | Theme default | Background color |
299| `BackgroundImage` | `string` | "" | Background image URL |
300| `BorderColor` | `string` | null | Border color |
301| `BorderWidth` | `double` | 1 | Border width in pixels |
302| `Theme` | `Theme` | Fluent2 | Chart theme |
303| `CssClass` | `string` | "" | Custom CSS class |
304
305#### Title & Content Properties
306| Property | Type | Default | Description |
307|----------|------|---------|-------------|
308| `Title` | `string` | "" | Main title text |
309| `SubTitle` | `string` | "" | Subtitle text |
310| `LinkCurvature` | `double` | 1 | Link curve intensity (0-1) |
311
312#### Animation Properties
313| Property | Type | Default | Description |
314|----------|------|---------|-------------|
315| `EnableAnimation` | `bool` | true | Enable/disable animations |
316| `AnimationDuration` | `double` | 2000 | Animation duration (ms) |
317| `AnimationDelay` | `double` | 0 | Animation delay (ms) |
318
319#### Accessibility & Interaction Properties
320| Property | Type | Default | Description |
321|----------|------|---------|-------------|
322| `EnableRTL` | `bool` | false | Enable right-to-left layout |
323| `TabIndex` | `double` | 0 | Keyboard tab index |
324| `AccessibilityDescription` | `string` | "" | Accessibility description |
325| `ID` | `string` | Auto-generated | Component ID |
326
327### Events Reference (16 Total Events)
328
329#### Rendering Events
330- **`NodeRendering`** - `SankeyNodeRenderEventArgs` - Fired when a node is rendered
331- **`LinkRendering`** - `SankeyLinkRenderEventArgs` - Fired when a link is rendered
332- **`LabelRendering`** - `SankeyLabelRenderEventArgs` - Fired when a label is rendered
333- **`LegendItemRendering`** - `SankeyLegendRenderEventArgs` - Fired before legend item renders
334
335#### Mouse Interaction Events
336- **`NodeClick`** - `SankeyNodeEventArgs` - Fired when node is clicked
337- **`LinkClick`** - `SankeyLinkEventArgs` - Fired when link is clicked
338- **`NodeEnter`** - `SankeyNodeEventArgs` - Fired when mouse enters node
339- **`NodeLeave`** - `SankeyNodeEventArgs` - Fired when mouse leaves node
340- **`LinkEnter`** - `SankeyLinkEventArgs` - Fired when mouse enters link
341- **`LinkLeave`** - `SankeyLinkEventArgs` - Fired when mouse leaves link
342
343#### UI Events
344- **`TooltipRendering`** - `SankeyTooltipRenderEventArgs` - Fired when tooltip renders
345- **`LegendItemHover`** - `SankeyLegendItemHoverEventArgs` - Fired on legend hover
346
347#### Lifecycle Events
348- **`Created`** - `Action` - Fired when component is created
349- **`SizeChanged`** - `SankeySizeChangedEventArgs` - Fired when component size changes
350
351#### Export/Print Events
352- **`PrintCompleted`** - `Action` - Fired when print completes
353- **`ExportCompleted`** - `SankeyExportedEventArgs` - Fired when export completes
354
355### Public Methods
356
357| Method | Parameters | Returns | Description |
358|--------|-----------|---------|-------------|
359| `ExportAsync` | `type (SankeyExportType), fileName, orientation?, allowDownload?, isBase64?` | `Task` | Export to PNG/JPEG/SVG/PDF |
360| `PrintAsync` | `elementRef?` | `Task` | Print the diagram |
361| `RefreshAsync` | None | `Task` | Re-render component |
362
363### Settings Objects
364
365- **SankeyNodeSettings**: Node appearance (Width, Padding, Alignment, Color, Offset)
366- **SankeyLinkSettings**: Link appearance (Color, Opacity, HighlightOpacity, InactiveOpacity, ColorType)
367- **SankeyLabelSettings**: Label styling (Visible, FontSize, FontFamily, FontWeight, Color, Padding)
368- **SankeyMargin**: Chart margins (Left, Right, Top, Bottom)
369- **SankeyTitleStyle**: Title styling (FontSize, FontFamily, FontWeight, FontStyle, Color)
370- **SankeySubtitleStyle**: Subtitle styling (FontSize, FontFamily, FontWeight, FontStyle, Color)
371- **SankeyLegendSettings**: Legend configuration (Visible, Position, Height, Width)
372- **SankeyTooltipSettings**: Tooltip configuration (Enable, Fill, Opacity)
373
374### Data Models
375
376| Model | Key Properties | Description |
377|-------|---|-------------|
378| **SankeyDataNode** | `Id`, `Label` (SankeyDataLabel), `Color`, `Width` | Represents a node |
379| **SankeyDataLabel** | `Text` | Node label text |
380| **SankeyDataLink** | `SourceId`, `TargetId`, `Value`, `Color`, `Opacity` | Represents a link/connection |
381
382### Enums
383
384| Enum | Values | Description |
385|------|--------|-------------|
386| **SankeyOrientation** | Auto, Horizontal, Vertical | Layout direction |
387| **SankeyNodeAlign** | None, Left, Center, Right | Node alignment |
388| **SankeyColorType** | Static, Source | Color mapping type |
389| **SankeyLegendPosition** | Top, Bottom, Left, Right | Legend position |
390| **SankeyExportType** | PNG, JPEG, SVG, PDF | Export format |
391| **Theme** | Bootstrap5, Fluent2, Material, Tailwind, Fabric, etc. | Chart theme |
392
393## Common Use Cases
394
395### Use Case 1: Energy Flow Visualization
396Visualize energy sources flowing to energy types and then to end-use sectors (residential, commercial, industrial).
397
398### Use Case 2: Website Traffic Analysis
399Show user traffic flow from entry points (search, social, direct) through pages to conversion goals.
400
401### Use Case 3: Budget Allocation
402Display budget flows from income sources through categories to final expenses.
403
404### Use Case 4: Supply Chain Flow
405Illustrate product movement from suppliers through manufacturing to distribution channels.
406
407### Use Case 5: User Journey Mapping
408Map user flow through application states, showing drop-offs and conversions at each stage.
409
410### Use Case 6: Data Pipeline Visualization
411Show data flow through processing stages in ETL pipelines or data transformation workflows.
412
413## Data Structure Requirements
414
415### Nodes
416Each node must have:
417- Unique `Id` (string)
418- `Label` with `Text` property
419
420### Links
421Each link must have:
422- `SourceId` matching a node Id
423- `TargetId` matching a node Id
424- `Value` representing flow magnitude (numeric)
425
426### Validation Tips
427- Ensure all link SourceId and TargetId reference existing node Ids
428- Values should be positive numbers
429- Avoid circular flows (node A → B → A) for clarity
430- Node Ids are case-sensitive
431
432## Troubleshooting Quick Tips
433
434**Diagram not showing:**
435- Verify Nodes and Links are properly initialized
436- Check that SfSankey has Width and Height set
437- Ensure Syncfusion services are registered in Program.cs
438
439**Links not appearing:**
440- Confirm SourceId and TargetId match existing node Ids exactly
441- Check that Value is greater than 0
442- Verify Links collection is bound to component
443
444**Styling not applying:**
445- Ensure theme CSS is referenced in App.razor or layout
446- Check for conflicting CSS styles
447- Verify color format is valid (hex, rgb, named color)
448
449**Events not firing:**
450- Confirm event handler method signature matches event args type
451- Check that event is properly bound in component markup
452- Verify component interactivity mode for .NET 8+ projects
453
454## Next Steps
455
456For detailed implementation of specific features, refer to the reference files listed in the Navigation Guide above. Each reference provides complete, self-contained documentation with examples and best practices.
457
458## Resources
459
460### Documentation & References
461- **Official Documentation**: https://blazor.syncfusion.com/documentation/sankey-chart/getting-started
462- **Component Demos**: https://blazor.syncfusion.com/demos/sankey-chart/default-functionalities
463- **Official API Reference**: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Sankey.html
464- **Local API Reference**: [references/api-reference.md](references/api-reference.md) - Comprehensive local API documentation with all properties, events, methods, and examples
465
466### Community & Support
467- **GitHub Examples**: https://github.com/SyncfusionExamples/
468- **Support**: https://www.syncfusion.com/support/
469- **NuGet Package**: https://www.nuget.org/packages/Syncfusion.Blazor.Sankey/