本文主要介绍如何手动添加series到图表中并将其绑定到数据源。图表控件可以被绑定到其他数据库,需要注意的是,在本文中我们会使用Microsoft Access数据库(.mdb)。
VB.NET
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<dxc:ChartControl Name="chartControl1">
<dxc:ChartControl.Diagram>
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.Label>
<dxc:AxisLabel Staggered="True" />
</dxc:AxisX2D.Label>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<dxc:XYDiagram2D.Series>
<dxc:BarSideBySideSeries2D Name="carSeries" ArgumentDataMember="Model"
ValueDataMember="Price" LabelsVisibility="True" />
</dxc:XYDiagram2D.Series>
</dxc:XYDiagram2D>
</dxc:ChartControl.Diagram>
<dxc:ChartControl.CrosshairOptions>
<dxc:CrosshairOptions ShowArgumentLine="True" ShowValueLabels="True"
ShowValueLine="True" />
</dxc:ChartControl.CrosshairOptions>
</dxc:ChartControl>
</Grid>
</Window>
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<dxc:ChartControl Name="chartControl1">
<dxc:ChartControl.Diagram>
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.Label>
<dxc:AxisLabel Staggered="True" />
</dxc:AxisX2D.Label>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<dxc:XYDiagram2D.Series>
<dxc:BarSideBySideSeries2D Name="carSeries" ArgumentDataMember="Model"
ValueDataMember="Price" LabelsVisibility="True" />
</dxc:XYDiagram2D.Series>
</dxc:XYDiagram2D>
</dxc:ChartControl.Diagram>
<dxc:ChartControl.CrosshairOptions>
<dxc:CrosshairOptions ShowArgumentLine="True" ShowValueLabels="True"
ShowValueLine="True" />
</dxc:ChartControl.CrosshairOptions>
</dxc:ChartControl>
</Grid>
</Window>
C#
<Window x:Class="DXCharts_Lesson2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<dxc:ChartControl Name="chartControl1">
<dxc:ChartControl.Diagram>
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.Label>
<dxc:AxisLabel Staggered="True" />
</dxc:AxisX2D.Label>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<dxc:XYDiagram2D.Series>
<dxc:BarSideBySideSeries2D Name="carSeries" ArgumentDataMember="Model"
ValueDataMember="Price" LabelsVisibility="True" />
</dxc:XYDiagram2D.Series>
</dxc:XYDiagram2D>
</dxc:ChartControl.Diagram>
<dxc:ChartControl.CrosshairOptions>
<dxc:CrosshairOptions ShowArgumentLine="True" ShowValueLabels="True"
ShowValueLine="True" />
</dxc:ChartControl.CrosshairOptions>
</dxc:ChartControl>
</Grid>
</Window>
<Window x:Class="DXCharts_Lesson2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<dxc:ChartControl Name="chartControl1">
<dxc:ChartControl.Diagram>
<dxc:XYDiagram2D>
<dxc:XYDiagram2D.AxisX>
<dxc:AxisX2D>
<dxc:AxisX2D.Label>
<dxc:AxisLabel Staggered="True" />
</dxc:AxisX2D.Label>
</dxc:AxisX2D>
</dxc:XYDiagram2D.AxisX>
<dxc:XYDiagram2D.Series>
<dxc:BarSideBySideSeries2D Name="carSeries" ArgumentDataMember="Model"
ValueDataMember="Price" LabelsVisibility="True" />
</dxc:XYDiagram2D.Series>
</dxc:XYDiagram2D>
</dxc:ChartControl.Diagram>
<dxc:ChartControl.CrosshairOptions>
<dxc:CrosshairOptions ShowArgumentLine="True" ShowValueLabels="True"
ShowValueLine="True" />
</dxc:ChartControl.CrosshairOptions>
</dxc:ChartControl>
</Grid>
</Window>
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/329.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/329.html