Skip to content

Commit 39fc99b

Browse files
authored
Merge pull request #6828 from syncfusion-content/983838-SanKeyUG
983838: Updated the UG content and example changes in the SanKey chart.
2 parents 9964d06 + 570f31f commit 39fc99b

File tree

10 files changed

+244
-247
lines changed

10 files changed

+244
-247
lines changed

blazor/sankey/customization.md

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
layout: post
33
title: Customization for Blazor Sankey Diagram | Syncfusion
4-
description: Explore various customization options available for enhancing the Blazor Sankey Diagram with background style, layout, and orientation configuration.
4+
description: Explore various customization options available for enhancing the Syncfusion Blazor Sankey Diagram with background style, layout, and orientation configuration.
55
platform: Blazor
66
control: Sankey
77
documentation: ug
88
---
99

1010
# Blazor Sankey Diagram: Customization
1111

12-
The Blazor Sankey Diagram offers extensive customization options to tailor its appearance and behavior to your specific needs. This guide covers customizing the background, dimensions, orientation, and right-to-left (RTL) support.
12+
The Blazor Sankey Diagram includes extensive options to tailor appearance and behavior. This guide covers background styling, dimensions, right-to-left (RTL) layout, and orientation.
1313

1414
## Setting Background
1515

16-
You can customize the background of the Sankey Diagram using the `BackgroundColor` and `BackgroundImage` properties. The `BackgroundColor` property allows you to set a solid background color for the chart. You can use any valid CSS color string, including hex codes, named colors, and RGB/RGBA values. The `BackgroundImage` property lets you set a background image for the sankey diagram. Specify the URL or path to the image file.
16+
Customize the diagram background using `BackgroundColor` and `BackgroundImage`. `BackgroundColor` accepts any valid CSS color (hex, named color, rgb/rgba). `BackgroundImage` applies an image by specifying its URL or file path.
1717

1818
{% tabs %}
1919
{% highlight razor %}
@@ -27,6 +27,7 @@ You can customize the background of the Sankey Diagram using the `BackgroundColo
2727
<SankeyLabelSettings Color="#FFFFFF" FontWeight="400" ></SankeyLabelSettings>
2828
<SankeyLegendSettings Visible="false"></SankeyLegendSettings>
2929
</SfSankey>
30+
3031
@code {
3132
string _backgroundColor = "#0b1320";
3233
public List<SankeyDataNode> Nodes = new List<SankeyDataNode>();
@@ -110,7 +111,7 @@ You can customize the background of the Sankey Diagram using the `BackgroundColo
110111

111112
## Dimensions (Width and Height)
112113

113-
Control the sankey diagram's dimensions using the `Width` and `Height` properties. You can specify values in pixels or percentages.
114+
Control diagram size using `Width` and `Height`. Values can be specified in pixels or percentages.
114115

115116
{% tabs %}
116117
{% highlight razor %}
@@ -120,6 +121,7 @@ Control the sankey diagram's dimensions using the `Width` and `Height` propertie
120121

121122
<SfSankey Width="@_width" Height="@_height" Nodes=@Nodes Links=@Links>
122123
</SfSankey>
124+
123125
@code {
124126
string _width = "800px";
125127
string _height = "450px";
@@ -190,15 +192,15 @@ Control the sankey diagram's dimensions using the `Width` and `Height` propertie
190192

191193
## Right-to-Left (RTL) Support
192194

193-
The Blazor Sankey diagram offers built-in support for Right-to-Left (RTL) languages. To enable RTL support, simply set the `EnableRTL` property to `true`. This will flip the entire layout of the Sankey diagram, including nodes, links, and any associated labels or legends.
195+
Enable RTL by setting `EnableRTL` to `true`. The entire layoutincluding nodes, links, labels, and legend—adapts to right‑to‑left flow.
194196

195-
**When you enable RTL support**
197+
**Effects of enabling RTL**
196198

197-
1. **Node Order**: The order of nodes will be reversed, with the first node appearing on the right side of the diagram.
198-
2. **Link Direction**: Links between nodes will flow from right to left.
199-
3. **Labels**: Node and link labels will be aligned to support RTL reading.
200-
4. **Tooltips**: If enabled, tooltips will be positioned appropriately for RTL layout.
201-
5. **Legend**: If a legend is present, its layout and order will also be reversed.
199+
1. Node order is reversed, placing the first node on the right.
200+
2. Link direction flows right‑to‑left.
201+
3. Labels align for RTL reading.
202+
4. Tooltips, if enabled, position appropriately for RTL.
203+
5. Legend layout and order are mirrored.
202204

203205
{% tabs %}
204206
{% highlight razor %}
@@ -208,6 +210,7 @@ The Blazor Sankey diagram offers built-in support for Right-to-Left (RTL) langua
208210

209211
<SfSankey Nodes=@Nodes Links=@Links EnableRTL="true">
210212
</SfSankey>
213+
211214
@code {
212215
string _width = "800px";
213216
string _height = "450px";
@@ -277,37 +280,24 @@ The Blazor Sankey diagram offers built-in support for Right-to-Left (RTL) langua
277280

278281
## Orientation
279282

280-
The `Orientation` property controls the flow direction of the Sankey Diagram. You can set it to `Horizontal` or `Vertical`. The default `Auto` setting automatically chooses the best orientation based on the sankey diagram's aspect ratio. Setting the orientation to vertical can be particularly useful for certain types of data or when you want to emphasize the top-down flow of information.
281-
282-
**When you switch the Sankey Diagram to vertical orientation, several aspects of the Sankey Diagram change:**
283-
284-
1. **Node Placement**: Nodes are arranged vertically from top to bottom, instead of left to right.
283+
Control the flow direction using the `Orientation` property. Values include `Horizontal`, `Vertical`, and `Auto` (default). Vertical orientation can be effective for tall layouts or to emphasize top‑down relationships.
285284

286-
2. **Link Direction**: Links flow downward, connecting nodes from top to bottom.
285+
**Changes in vertical orientation**
287286

288-
3. **Label Positioning**:
289-
- Node labels are typically positioned to the right of each node.
290-
- Link labels, if enabled, are oriented to align with the vertical flow.
291-
292-
4. **Space Utilization**:
293-
- Vertical orientation often allows for better use of space when dealing with many nodes or long node labels.
294-
- It can be particularly effective for tall, narrow layouts.
295-
296-
5. **Data Interpretation**:
297-
- The top-down flow can imply a hierarchical or sequential relationship between nodes.
298-
- It may be more intuitive for certain types of data, such as organizational charts or process flows.
299-
300-
6. **Responsiveness**:
301-
- Vertical layouts can sometimes be more responsive on mobile devices or narrow screen widths.
302-
303-
7. **Scrolling Behavior**:
304-
- For large diagrams, users will scroll vertically instead of horizontally, which can be more natural on most devices.
287+
1. Nodes are arranged from top to bottom.
288+
2. Links flow downward between nodes.
289+
3. Labels align with the vertical flow (node labels typically to the right).
290+
4. Space can be used more efficiently for many nodes or longer labels.
291+
5. A top‑down arrangement can imply hierarchical or sequential relationships.
292+
6. Vertical layouts can be more responsive on narrow screens.
293+
7. Large diagrams scroll vertically instead of horizontally.
305294

306295
{% tabs %}
307296
{% highlight razor %}
308297

309298
<SfSankey Width="@_width" Height="@_height" Nodes=@Nodes Links=@Links Orientation="SankeyOrientation.Vertical">
310299
</SfSankey>
300+
311301
@code {
312302
string _width = "650px";
313303
string _height = "650px";
@@ -378,10 +368,10 @@ The `Orientation` property controls the flow direction of the Sankey Diagram. Yo
378368

379369
## Key Points
380370

381-
* Combining background customizations can create visually appealing charts.
382-
* Using percentage values for `Width` and `Height` makes the chart responsive to different screen sizes.
383-
* `EnableRTL` is crucial for supporting right-to-left languages.
384-
* `Orientation` determines the layout direction of the sankey diagram, either horizontal or vertical.
371+
* Background color and image can be combined for richer visuals.
372+
* Percentage values for `Width` and `Height` support responsive layouts.
373+
* `EnableRTL` provides right‑to‑left language support.
374+
* `Orientation` determines horizontal or vertical layout.
385375

386376
## See also
387377

blazor/sankey/data-binding.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
---
22
layout: post
33
title: Data Binding for Blazor Sankey Diagram | Syncfusion
4-
description: Checkout and learn about data binding with Blazor Sankey Diagram and how to implement it effectively.
4+
description: Learn how to bind nodes and links to the Syncfusion Blazor Sankey Diagram, including data models, REST API binding and JSON response format.
55
platform: Blazor
66
control: Sankey
77
documentation: ug
88
---
99

1010
# Data Binding in the Blazor Sankey Diagram
1111

12-
The Blazor Sankey Diagram is designed to visualize relationships and flows between categories using nodes and links. Data binding allows you to easily provide the necessary information for the sankey diagram to render effectively. Below, we explore how to bind data to the sankey diagram in Blazor.
12+
The Blazor Sankey Diagram visualizes relationships and flows between categories using nodes and links. Data binding supplies the node and link information required to render the diagram effectively.
1313

1414
## Overview of Data Binding
1515

1616
The Sankey Diagram accepts data for:
1717

18-
1. **Nodes**: Represent entities or categories in the flow.
19-
2. **Links**: Represent the connections and their magnitude between the nodes.
18+
1. **Nodes**: Entities or categories in the flow.
19+
2. **Links**: Connections between nodes, including the magnitude of each flow.
2020

21-
The data can be bound using collections of objects that define the properties of nodes and links. The component dynamically generates the diagram based on this data.
21+
Bind data using collections of objects that define node and link properties. The component generates the diagram based on this data.
2222

2323
## Understanding Data Models
24-
The Blazor Sankey Diagram uses predefined data models for nodes and links. These models are already available in the `Syncfusion.Blazor.Sankey` namespace. Here's an overview of their key properties:
24+
The Blazor Sankey Diagram uses predefined data models for nodes and links available in the `Syncfusion.Blazor.Sankey` namespace. Key properties include:
2525

2626
### SankeyDataNode
27-
- `Id`: A string property that serves as a unique identifier for the node.
28-
- `Label`: An object of type `SankeyDataLabel` that can be used to customize the node's label.
27+
- `Id`: Unique identifier for the node.
28+
- `Label`: An instance of `SankeyDataLabel` to customize the node label.
2929

3030
### SankeyDataLink
31-
- `SourceId`: A string property identifying the source node of the link.
32-
- `TargetId`: A string property identifying the target node of the link.
33-
- `Value`: A double property representing the weight or magnitude of the connection.
31+
- `SourceId`: Identifier of the source node.
32+
- `TargetId`: Identifier of the target node.
33+
- `Value`: Weight or magnitude of the connection.
3434

35-
There's no need to define these classes yourself as they are provided by the Syncfusion<sup style="font-size:70%">&reg;</sup> library.
35+
These types are provided by the Syncfusion<sup style="font-size:70%">&reg;</sup> library; custom class definitions are not required.
3636

3737
## Binding Data to the Sankey Diagram
38-
To use the Sankey Diagram, you need to create collections of `SankeyDataNode` and `SankeyDataLink` objects and bind them to the component. Here's how you can do this.
38+
Create collections of `SankeyDataNode` and `SankeyDataLink` and assign them to the component.
3939

40-
Below is an example of how to bind data to the Sankey Diagram in a Blazor application:
40+
Below is an example of binding data to the Sankey Diagram in a Blazor application:
4141

4242
{% tabs %}
4343
{% highlight razor %}
@@ -61,7 +61,7 @@ Below is an example of how to bind data to the Sankey Diagram in a Blazor applic
6161
new SankeyDataNode() { Id = "Green Coffee" },
6262
new SankeyDataNode() { Id = "North America" },
6363
new SankeyDataNode() { Id = "Europe" },
64-
new SankeyDataNode() { Id = "Asia Pacific" },
64+
new SankeyDataNode() { Id = "Asia Pacific" }
6565
};
6666
Links = new List<SankeyDataLink>()
6767
{
@@ -81,7 +81,7 @@ Below is an example of how to bind data to the Sankey Diagram in a Blazor applic
8181
new SankeyDataLink() { SourceId = "Instant Coffee", TargetId = "Asia Pacific", Value = 15 },
8282
new SankeyDataLink() { SourceId = "Green Coffee", TargetId = "North America", Value = 10 },
8383
new SankeyDataLink() { SourceId = "Green Coffee", TargetId = "Europe", Value = 8 },
84-
new SankeyDataLink() { SourceId = "Green Coffee", TargetId = "Asia Pacific", Value = 7 },
84+
new SankeyDataLink() { SourceId = "Green Coffee", TargetId = "Asia Pacific", Value = 7 }
8585
};
8686
base.OnInitialized();
8787
}
@@ -94,16 +94,16 @@ Below is an example of how to bind data to the Sankey Diagram in a Blazor applic
9494

9595
### Key Points
9696

97-
- The `Nodes` parameter expects a collection of `SankeyDataNode` objects.
98-
- The `Links` parameter expects a collection of `SankeyDataLink` objects.
99-
- Ensure that `SourceId` and `TargetId` in `SankeyDataLink` match the `Id` values in `SankeyDataNode`.
97+
- `Nodes` expects a collection of `SankeyDataNode` objects.
98+
- `Links` expects a collection of `SankeyDataLink` objects.
99+
- `SourceId` and `TargetId` values in `SankeyDataLink` must match the corresponding `Id` values in `SankeyDataNode`.
100100

101101
## Advanced Binding Scenarios
102102

103-
You can bind data from various sources such as:
104-
- REST APIs: Fetch data dynamically using HTTP requests.
105-
- Databases: Load data using Entity Framework or similar ORM tools.
106-
- JSON Files: Deserialize JSON data into the node and link models.
103+
Data can be sourced from:
104+
- REST APIs: Fetch data dynamically via HTTP requests.
105+
- Databases: Load data using Entity Framework or another ORM.
106+
- JSON files: Deserialize JSON into node and link models.
107107

108108
### Example: Binding Data from a REST API
109109

@@ -138,7 +138,7 @@ You can bind data from various sources such as:
138138

139139

140140
### Updated REST API Example
141-
Ensure that your API endpoint provides a JSON response in the following format:
141+
The API endpoint should return a JSON response in the following format:
142142

143143
{% tabs %}
144144
{% highlight json %}
@@ -164,4 +164,4 @@ Ensure that your API endpoint provides a JSON response in the following format:
164164

165165
* [Nodes](./nodes)
166166
* [Links](./links)
167-
* [Labels](./labels)
167+
* [Labels](./labels)

0 commit comments

Comments
 (0)