Back to Devexpress

SankeyDiagramControl.SourceDataMember Property

wpf-devexpress-dot-xpf-dot-charts-dot-sankey-dot-sankeydiagramcontrol-c038ac9a.md

latest5.2 KB
Original Source

SankeyDiagramControl.SourceDataMember Property

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

Namespace : DevExpress.Xpf.Charts.Sankey

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

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public string SourceDataMember { get; set; }
vb
Public Property SourceDataMember As String

Property Value

TypeDescription
String

The name of a data member that contains source node labels.

|

Remarks

The following example shows how to bind Sankey Diagram Control and specify the SourceDataMember, TargetDataMember, and WeightDataMember properties:

xaml
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:SankeySample"
        xmlns:dxsa="http://schemas.devexpress.com/winfx/2008/xaml/sankey" 
        x:Class="SankeySample.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <dxsa:SankeyDiagramControl DataSource="{Binding Data}" 
                                   SourceDataMember="Source" 
                                   TargetDataMember="Target" 
                                   WeightDataMember="Value">
            <dxsa:SankeyDiagramControl.DataContext>
                <local:SankeyViewModel/>
            </dxsa:SankeyDiagramControl.DataContext>
        </dxsa:SankeyDiagramControl>
    </Grid>
</Window>
csharp
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; }
    }
}
vb
Imports System.Collections.Generic

Namespace SankeySample
    '...
    Public Class SankeyViewModel
        Public ReadOnly Property Data As List(Of SankeyItem)
            Get
                Return GetData()
            End Get
        End Property

        Public Function GetData() As List(Of SankeyItem)
            Dim data As List(Of SankeyItem) = New List(Of SankeyItem) From {
                New SankeyItem With {
                    .Source = "France", .Target = "UK", .Value = 53
                },
                New SankeyItem With {
                    .Source = "Australia", .Target = "UK", .Value = 72
                },
                New SankeyItem With {
                    .Source = "France", .Target = "Canada", .Value = 81
                },
                New SankeyItem With {
                    .Source = "China", .Target = "Canada", .Value = 96
                },
                New SankeyItem With {
                    .Source = "UK", .Target = "France", .Value = 61
                },
                New SankeyItem With {
                    .Source = "Canada", .Target = "France", .Value = 89
                }
            }
            Return data
        End Function
    End Class

    Public Class SankeyItem
        Public Property Source As String
        Public Property Target As String
        Public Property Value As Double
    End Class
End Namespace

Result:

See Also

TargetDataMember

WeightDataMember

SankeyDiagramControl Class

SankeyDiagramControl Members

DevExpress.Xpf.Charts.Sankey Namespace