wpf-devexpress-dot-xpf-dot-charts-dot-sankey-dot-sankeydiagramcontrol-6c595148.md
Specifies the object from which the Sankey Diagram Control retrieves its data items.
Namespace : DevExpress.Xpf.Charts.Sankey
Assembly : DevExpress.Xpf.Charts.v25.2.dll
NuGet Package : DevExpress.Wpf.Charts
public object DataSource { get; set; }
Public Property DataSource As Object
| Type | Description |
|---|---|
| Object |
The data source object.
|
You can set the DataSource property to an object that implements any of the following interfaces: IList, IListSource, or IBindingList.
To bind Sankey Diagram Control to a data source, you also need to 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.
<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>
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; }
}
}
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