All docs
21.2 (EAP/Beta)
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
A newer version of this page is available. Switch to the current version.

SankeyDiagramControl Class

Displays a multilevel Sankey diagram.

Namespace: DevExpress.Xpf.Charts.Sankey

Assembly: DevExpress.Xpf.Charts.v20.2.dll


public class SankeyDiagramControl :


A Sankey diagram depicts transfers or flows between entities (also called nodes) in a system. This diagram can help locate the most important contributions to a flow.

The following image displays diagram elements:

sankey diagram elements

Each link connects the source and target nodes and has an assigned value - weight. The width of link is proportional to its weight.


Run Demo: Colorizer

Add to the Project

Drag and drop the SankeyDiagramControl component from the Toolbox to the form to add a Sankey diagram to the project.

This adds references to the following assemblies to the project:

  • DevExpress.Charts.v20.2.Core.dll
  • DevExpress.Data.v20.2.dll
  • DevExpress.DataVisualization.v20.2.Core.dll
  • DevExpress.Mvvm.v20.2.dll
  • DevExpress.Printing.v20.2.Core.dll
  • DevExpress.Xpf.Charts.v20.2.dll
  • DevExpress.Xpf.Core.v20.2.dll
  • DevExpress.Xpf.Printing.v20.2.dll

Bind to Data

Use the DataSource property to bind the control to a data source. You can assign this property an object that implements any of the following interfaces: IList, IListSource, or IBindingList.

Then, specify the names of data members that store data for source nodes, target nodes, and weights:

  • SourceDataMember - Specifies the name of a data member that contains source node labels.

  • TargetDataMember - Specifies the name of a data member that contains target node labels.

  • WeightDataMember (Optional) - Specifies the name of a data member that contains link weights. If the WeightDataMember property is not specified, weights are equal to 1.

        Title="MainWindow" Height="450" Width="800">
        <dxsa:SankeyDiagramControl DataSource="{Binding Data}" 
                <dxsa:SankeyTitle Content="Export/Import" 
using System.Collections.Generic;
using System.Windows;

namespace SankeySample {
    public class SankeyViewModel {
        public List<SankeyItem> Data {
            get { return GetData(); }
        public List<SankeyItem> GetData() {
            List<SankeyItem> data = new List<SankeyItem>{                
                new SankeyItem { Source = "France", Target = "UK", Value = 53 },
                new SankeyItem { Source = "Australia", Target = "UK", Value = 72 },
                new SankeyItem { Source = "France", Target = "Canada", Value = 81 },
                new SankeyItem { Source = "China", Target = "Canada", Value = 96 },
                new SankeyItem { Source = "UK", Target = "France", Value = 61 },
                new SankeyItem { Source = "Canada", Target = "France", Value = 89 } 
            return data;
    public class SankeyItem {
        public string Source { get; set; }
        public string Target { get; set; }
        public double Value { get; set; }


Customize Nodes

Assign a SankeyNodeLabel object to the SankeyDiagramControl.NodeLabel property to specify node label settings such as text orientation:

        <dxsa:SankeyNodeLabel TextOrientation="BottomToTop"/>

Initialize the SankeyDiagramControl.NodeTemplate property with a DataTemplate object to customize node label appearance.

        <Rectangle Stroke="Black" 

For more information about template configuration, refer to the following topic: Data Templating Overview.

Sort Nodes

The control automatically arranges nodes based on underlying data. If you wish to rearrange nodes or specify a custom sort order, create a class that implements IComparer<SankeyNode>. Then, assign an object of this class to the NodeComparer property.

The following code arranges nodes in descending order of their TotalWeight values:

using DevExpress.Xpf.Charts.Sankey;
public class MyNodeComparer : IComparer<SankeyNode> {
    public int Compare(SankeyNode x, SankeyNode y) {
        return y.TotalWeight.CompareTo(x.TotalWeight);

The Sankey diagram control uses the SankeyPaletteColorizer to color nodes. A new color from the palette is applied to each node with a unique label. Colors repeat if the number of unique labels exceeds the number of palette colors. To apply a gradient fill to links, the control utilizes the source and target node colors. Specify the SankeyPaletteColorizer.Palette property to change colors that are used to paint a Sankey diagram. You can select one of predefined palettes.

Sankey Palette colorizer configuration

    <dxsa:SankeyPaletteColorizer LinkBrush="Gray">

You can also create a new palette as follows:

    <dxsa:SankeyPaletteColorizer LinkBrush="Gray">

Custom Colorizer

To paint links and nodes based on a custom algorithm, create a class derived from the SankeyColorizerBase class. Then, assign an object of this class to the Colorizer property.

The following example implements a colorizer that applies random colors to nodes and specifies colors used to apply a gradient fill to links.

A custom colorizer is applied to a sankey diagram

    <local:MyColorizer LinkSourceColor="Yellow" LinkTargetColor="Red" />
public class MyColorizer : SankeyColorizerBase {
    readonly Random rand = new Random();
    readonly Dictionary<string, Color> KeyColorPairs = new Dictionary<string, Color>();
    public Color LinkSourceColor { get; set; }
    public Color LinkTargetColor { get; set; }
    public override Color GetLinkSourceColor(SankeyLink link) {
        return LinkSourceColor;
    public override Color GetLinkTargetColor(SankeyLink link) {
        return LinkTargetColor;
    public override Color GetNodeColor(SankeyNode info) {
        if (!KeyColorPairs.TryGetValue((string)info.Tag, out Color nodeColor)) {
            nodeColor = GenerateColor();
            KeyColorPairs.Add((string)info.Tag, nodeColor);
        return nodeColor;
    private Color GenerateColor() {
        return Color.FromRgb((byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256));

Customize Tooltips

Tooltips are shown when the mouse pointer hovers over a node or link. Use the ToolTipOptions, SankeyToolTipOptions.LinkToolTipEnabled and SankeyToolTipOptions.NodeToolTipEnabled properties to access tooltip settings and disable/enable tooltips.

        <dxsa:SankeyToolTipOptions OpenMode="OnHover" 

Initialize the SankeyDiagramControl.ToolTipTemplate property with a DataTemplate to customize tooltip appearance.

        <Border BorderThickness="1" 
            <StackPanel Orientation="Vertical" Margin="8">
                <Label Foreground="White" 
                Content="{Binding Path=Info.ToolTipText}" />

To print the control, use one of the methods below:

The following methods allow you to export the control to various formats:

The code below specifies the resulting Sankey diagram image’s width to fit the document width and exports a Sankey diagram to a PDF file:

sankeyDiagram.PrintOptions = new SankeyPrintOptions { 
    SizeMode = DevExpress.Xpf.Charts.PrintSizeMode.ProportionalZoom 


See Also