简要说明
圆环图 是由 DoughnutSeriesView 对象来表示的,此对象属于 饼、圆环和漏斗系列。 当需要比较相同系列中不同点参数的百分比取值时、并且以易于理解的圆环切块来说明这些取值时,使用这种视图。
在下面的插图中显示了一个圆环图。 注意,如果图表包含多个 DoughnutSeriesView (以及 PieSeriesView) 类型的系列,那么就根据 SimpleDiagram.Dimension 和 SimpleDiagram.LayoutDirection 属性值,在相同的图象中显示所有这些系列。
注意,要控制圆环内孔的尺寸,则使用 DoughnutSeriesView.HoleRadiusPercent (或 Doughnut3DSeriesView.HoleRadiusPercent) 属性。 例如,在上面的插图中,左侧图表的此属性值被设置为 0。
图表类型特征
下表列出了这种图表类型的主要特征。
特征 |
取值 |
---|---|
系列视图类型 | DoughnutSeriesView |
图象类型 | 2D- SimpleDiagram |
每个数据点的参数个数 | 1 |
每个数据点的取值个数 | 1 |
注意 |
---|
要获得关于哪些图表类型可以与 圆环图 组合使用的信息,请参阅 组合使用不同的系列视图 文档。 |
示例
下面的示例演示了在运行时刻如何创建 ChartControl (拥有一个 DoughnutSeriesView 类型的系列),设置它的常规属性,并把图表添加到窗体中。 在继续本示例之前,首先要在 Visual Studio 中创建一个 Windows 窗体应用程序,并把所有 必需的程序集 包含到项目的“引用”列表中。
然后,把下列代码添加到 Form.Load 事件处理程序。
C# | 复制代码 |
---|---|
using System; using System.Windows.Forms; using DevExpress.XtraCharts; // ... private void Form1_Load(object sender, EventArgs e) { // Create a new chart. ChartControl DoughnutChart = new ChartControl(); // Create a doughnut series. Series series1 = new Series("Series 1", ViewType.Doughnut); // Populate the series with points. series1.Points.Add(new SeriesPoint("Russia", 17.0752)); series1.Points.Add(new SeriesPoint("Canada", 9.98467)); series1.Points.Add(new SeriesPoint("USA", 9.63142)); series1.Points.Add(new SeriesPoint("China", 9.59696)); series1.Points.Add(new SeriesPoint("Brazil", 8.511965)); series1.Points.Add(new SeriesPoint("Australia", 7.68685)); series1.Points.Add(new SeriesPoint("India", 3.28759)); series1.Points.Add(new SeriesPoint("Others", 81.2)); // Add the series to the chart. DoughnutChart.Series.Add(series1); // Adjust the value numeric options of the series. series1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; series1.PointOptions.ValueNumericOptions.Precision = 0; // Specify how series points are sorted. series1.SeriesPointsSorting = SortingMode.Ascending; series1.SeriesPointsSortingKey = SeriesPointKey.Argument; // Specify the behavior of series labels. ((DoughnutSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.TwoColumns; ((DoughnutSeriesLabel)series1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default; ((DoughnutSeriesLabel)series1.Label).ResolveOverlappingMinIndent = 5; ((PiePointOptions)series1.PointOptions).PointView = PointView.ArgumentAndValues; // Adjust the view-type-specific options of the series. ((DoughnutSeriesView)series1.View).ExplodedPoints.Add(series1.Points[0]); ((DoughnutSeriesView)series1.View).ExplodedDistancePercentage = 30; // Access the diagram's options. ((SimpleDiagram)DoughnutChart.Diagram).Dimension = 2; // Add a title to the chart and hide the legend. ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "3D Doughnut Chart"; DoughnutChart.Titles.Add(chartTitle1); DoughnutChart.Legend.Visible = false; // Add the chart to the form. DoughnutChart.Dock = DockStyle.Fill; this.Controls.Add(DoughnutChart); } |
Visual Basic | 复制代码 |
---|---|
Imports System Imports System.Windows.Forms Imports DevExpress.XtraCharts ' ... Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load ' Create a new chart. Dim DoughnutChart As New ChartControl() ' Create a doughnut series. Dim series1 As New Series("Series 1", ViewType.Doughnut) ' Populate the series with points. series1.Points.Add(New SeriesPoint("Russia", 17.0752)) series1.Points.Add(New SeriesPoint("Canada", 9.98467)) series1.Points.Add(New SeriesPoint("USA", 9.63142)) series1.Points.Add(New SeriesPoint("China", 9.59696)) series1.Points.Add(New SeriesPoint("Brazil", 8.511965)) series1.Points.Add(New SeriesPoint("Australia", 7.68685)) series1.Points.Add(New SeriesPoint("India", 3.28759)) series1.Points.Add(New SeriesPoint("Others", 81.2)) ' Add the series to the chart. DoughnutChart.Series.Add(series1) ' Adjust the value numeric options of the series. series1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent series1.PointOptions.ValueNumericOptions.Precision = 0 ' Specify how series points are sorted. series1.SeriesPointsSorting = SortingMode.Ascending series1.SeriesPointsSortingKey = SeriesPointKey.Argument ' Specify the behavior of series labels. CType(series1.Label, DoughnutSeriesLabel).Position = PieSeriesLabelPosition.TwoColumns CType(series1.Label, DoughnutSeriesLabel).ResolveOverlappingMode = _ ResolveOverlappingMode.Default CType(series1.Label, DoughnutSeriesLabel).ResolveOverlappingMinIndent = 5 CType(series1.PointOptions, PiePointOptions).PointView = PointView.ArgumentAndValues ' Adjust the view-type-specific options of the series. CType(series1.View, DoughnutSeriesView).ExplodedPoints.Add(series1.Points(0)) CType(series1.View, DoughnutSeriesView).ExplodedDistancePercentage = 30 ' Access the diagram's options. CType(DoughnutChart.Diagram, SimpleDiagram).Dimension = 2 ' Add a title to the chart and hide the legend. Dim chartTitle1 As New ChartTitle() chartTitle1.Text = "3D Doughnut Chart" DoughnutChart.Titles.Add(chartTitle1) DoughnutChart.Legend.Visible = False ' Add the chart to the form. DoughnutChart.Dock = DockStyle.Fill Me.Controls.Add(DoughnutChart) End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1047。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |