数据可视化新方式,SankeyDiagramControl类的使用你不能错过!(Part 1)

下载DevExpress v20.2完整版 

上DevExpress中文网,获取第一手最新产品资讯!

DevExpress WinForms能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还是分析处理大批量的业务数据,它都能轻松胜任!体验?点击下载>>

命名空间DevExpress.XtraCharts.Sankey

程序集:DevExpress.XtraCharts.v20.2.UI.dll

声明

C#

[SerializationContext(typeof(SankeySerializationContext))]
public class SankeyDiagramControl :
Control,
ISankeyContainer,
IToolTipControlClient,
ISupportLookAndFeel,
ISankeyRenderProvider,
IChartRenderProvider,
IPrintable,
IBasePrintable

VB.NET

<SerializationContext(GetType(SankeySerializationContext))>
Public Class SankeyDiagramControl
Inherits Control
Implements ISankeyContainer,
IToolTipControlClient,
ISupportLookAndFeel,
ISankeyRenderProvider,
IChartRenderProvider,
IPrintable,
IBasePrintable

注释

Sankey图表描述系统中实体(也称为节点)之间的转移或流,该图可以帮助您找到对流程最重要的贡献。

下图显示了图元素:

DevExpress WinForms使用教程:Sankey Diagram控件

每个链接都连接源节点和目标节点,并具有分配的值-权重,链接的宽度与其重量成正比。

添加到项目

将SankeyDiagramControl组件从Toolbox拖放到窗体中,来将Sankey图添加到项目中。

DevExpress WinForms使用教程:Sankey Diagram控件

这会将对以下程序集的引用添加到项目中:

  • DevExpress.Charts.v20.2.Core.dll
  • DevExpress.Data.Desktop.v20.2.dll
  • DevExpress.Data.v20.2.dll
  • DevExpress.Printing.v20.2.Core.dll
  • DevExpress.XtraPrinting.v20.2.dll
  • DevExpress.Utils.v20.2.dll
  • DevExpress.Utils.v20.2.Core.dll
  • DevExpress.XtraBars.v20.2.dll
  • DevExpress.XtraCharts.v20.2.dll
  • DevExpress.XtraCharts.v20.2.UI.dll
  • DevExpress.XtraCharts.v20.2.Wizard.dll
  • DevExpress.XtraEditors.v20.2.dll

绑定到数据

使用DataSource属性将控件绑定到数据源,您可以为该属性分配一个实现以下任何接口的对象:IList,IListSource或IBindingList。

然后指定存储用于源节点、目标节点和权重数据的数据成员名称:

  • SourceDataMember - 指定包含源节点标签的数据成员的名称。
  • TargetDataMember - 指定包含目标节点标签数据成员的名称。
  • WeightDataMember (Optional) - 指定包含链接权重的数据成员名称,如果未指定WeightDataMember属性,则权重等于1。

C#

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.NET

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

结果:

DevExpress WinForms使用教程:Sankey Diagram控件


DevExpress技术交流群2:775869749      欢迎一起进群讨论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
================================== ==注意:一共2个压缩包,这是第2个== ================================== *提示:无自动安装程序,包含所有源码、例子、帮助,请按照安装顺序安装!!! New Features in 13.1.4 (VCL Product Line) Breaking Changes To learn about breaking changes in this version, please refer to the following page: Breaking Changes in 13.1.4 (VCL Product Line) Known Issues To learn about known issues in this version, please refer to the following page: Known Issues in 13.1.4 (VCL Product Line) The following sections list all minor and major changes in DevExpress VCL 13.1.4. Note that products, controls and libraries which aren't mentioned in the list below are included in the unified installer for compatibility, but have not been updated. Enhancements and Updates New Features/Updates VCL Subscription ExpressTile Control ExpressDataController Resolved Issues ExpressBars Suite ExpressLayout Control ExpressNavBar ExpressPageControl ExpressPivotGrid Suite ExpressPrinting System ExpressQuantumGrid Suite ExpressQuantumTreeList Suite ExpressScheduler Suite ExpressSkins Library ExpressSpreadSheet ExpressTile Control ExpressVerticalGrid Suite ExpressDataController ExpressEditors Library ExpressLibrary Installation (VCL) New Features/Updates VCL Subscription S170932 - Documentation - Describe that the ExpressLayout Control and ExpressDocking Library are incompatible ExpressTile Control S172299 - Center the Back button and title text vertically within the title Common Libraries ExpressDataController S172107 - Add the capability to disable multi-threaded operations at the level of custom data sources (TcxCustomDataSource descendants) Resolved Issues ExpressBars Suite Q476901 - Documentation - The "Ribbon Application Menu" topic does not contain the menu creation steps that are specific to TdxRibbonBackstageView Q452658 - Documentation - The TdxCustomRibbonGalleryItem.GalleryGroups property is not marked as deprecated and is used in topics instead of TdxCustomRibbonGalleryItem.GalleryCategories Q513198 -

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值