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