Back to Devexpress

SankeyDiagramControl.TargetDataMember Property

windowsforms-devexpress-dot-xtracharts-dot-sankey-dot-sankeydiagramcontrol-deba2fa7.md

latest7.3 KB
Original Source

SankeyDiagramControl.TargetDataMember Property

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

Namespace : DevExpress.XtraCharts.Sankey

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

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

Property Value

TypeDescription
String

The name of a data source field that stores target node labels.

|

Remarks

Specify the DataSource property to bind a Sankey diagram to data. You can assign an object of a class that implements one of the following interfaces: IList, IListSource or IBindingList.

Then, define 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 data for source node labels.

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

  • WeightDataMember (Optional) - Specifies the name of a data member that contains data for link weights. If unspecified, weights equal 1.

  • C#

  • VB.NET

csharp
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.XtraCharts.Sankey;
namespace SankeySample {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
            sankeyDiagramControl1.DataSource = GetSankeyItems();
            sankeyDiagramControl1.SourceDataMember = "Source";
            sankeyDiagramControl1.TargetDataMember = "Target";            
            sankeyDiagramControl1.WeightDataMember = "Value";
            sankeyDiagramControl1.Titles.Add(new SankeyTitle { Text = "Export/Import" });
        }
        List<SankeyItem> GetSankeyItems() {
            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
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports DevExpress.XtraCharts.Sankey

Namespace SankeySample
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            sankeyDiagramControl1.DataSource = GetSankeyItems()
            sankeyDiagramControl1.SourceDataMember = "Source"
            sankeyDiagramControl1.TargetDataMember = "Target"            
            sankeyDiagramControl1.WeightDataMember = "Value"
            sankeyDiagramControl1.Titles.Add(New SankeyTitle With {
                .Text = "Export/Import"
            })
        End Sub

        Private Function GetSankeyItems() 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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TargetDataMember property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/SankeyChart/SankeyItemControlProvider.cs#L102

csharp
sankey.SourceDataMember = flatData.GetDisplayTextColumn(dashboardItem.Metadata.Source.UniqueId).Name;
sankey.TargetDataMember = flatData.GetDisplayTextColumn(dashboardItem.Metadata.Target.UniqueId).Name;
if(dashboardItem.Metadata.Weight != null)

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/SankeyChart/SankeyItemControlProvider.vb#L114

vb
sankey.SourceDataMember = flatData.GetDisplayTextColumn(dashboardItem.Metadata.Source.UniqueId).Name
sankey.TargetDataMember = flatData.GetDisplayTextColumn(dashboardItem.Metadata.Target.UniqueId).Name
If dashboardItem.Metadata.Weight IsNot Nothing Then

See Also

SankeyDiagramControl Class

SankeyDiagramControl Members

DevExpress.XtraCharts.Sankey Namespace