今天为大家介绍如何用DevExpress DXCharts创建2D饼图。首先将ChartControl.Diagram属性部署到SimpleDiagram2D,然后添加两个PieSeries2D对象到图像的 Diagram.Series集合,详情请参考下面的示例,这个示例同时显示了如何添加图例(显示序列名称)到图表:
<Window x:Class="PieDonut2DChart.Window1" 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="Window1" Height="350" Width="620"> <Grid> <dxc:ChartControl Name="chartControl1"> <dxc:ChartControl.Diagram> <dxc:SimpleDiagram2D> <dxc:SimpleDiagram2D.Series> <dxc:PieSeries2D HoleRadiusPercent="0"> <dxc:PieSeries2D.Points> <dxc:SeriesPoint Argument="A" Value="1" /> <dxc:SeriesPoint Argument="B" Value="3" /> <dxc:SeriesPoint Argument="C" Value="7" /> <dxc:SeriesPoint Argument="D" Value="4" /> </dxc:PieSeries2D.Points> <!--region #Model--> <dxc:PieSeries2D.Model> <dxc:GlarePie2DModel /> </dxc:PieSeries2D.Model> <!--endregion #Model--> <dxc:PieSeries2D.PointOptions> <dxc:PointOptions> <dxc:PointOptions.ValueNumericOptions> <dxc:NumericOptions Format="Percent" Precision="0" /> </dxc:PointOptions.ValueNumericOptions> </dxc:PointOptions> </dxc:PieSeries2D.PointOptions> <!--region #LegendPointOptions--> <dxc:PieSeries2D.LegendPointOptions> <dxc:PointOptions Pattern="{}{A}: {V}" /> </dxc:PieSeries2D.LegendPointOptions> <!--endregion #LegendPointOptions--> </dxc:PieSeries2D> </dxc:SimpleDiagram2D.Series> </dxc:SimpleDiagram2D> </dxc:ChartControl.Diagram> <dxc:ChartControl.Legend> <dxc:Legend /> </dxc:ChartControl.Legend> </dxc:ChartControl> </Grid> </Window>结果如下:
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/455.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/455.html