简要说明
饼图 是由 Pie3DSeriesView 对象来表示的,此对象属于 饼、圆环和漏斗系列视图。 当需要比较相同系列中不同点参数的百分比取值、并且以易于理解的饼切块说明这些取值时,这种视图是有用的。 另外,三维外观使旋转图表变得可能,从而以一种吸引眼球且易于理解的方式来放置饼切块。
在下面的插图中显示了一个饼图。
图表类型特征
下表列出了这种图表类型的主要特征。
特征 |
取值 |
---|---|
系列视图类型 | Pie3DSeriesView |
图象类型 | SimpleDiagram3D |
每个数据点的参数个数 | 1 |
每个数据点的取值个数 | 1 |
注意 |
---|
要获得关于哪些图表类型可以与 饼图 组合使用的信息,请参阅 组合使用不同的系列视图 文档。 |
示例
下面的示例演示了在运行时刻如何创建 ChartControl (拥有一个 Pie3DSeriesView 类型的系列),设置它的常规属性,并把图表添加到窗体中。 在继续本示例之前,首先要在 Visual Studio 中创建一个 Windows 窗体应用程序,并把所有 必需的程序集 包含到项目的“引用”列表中。
然后,把下列代码添加到 Form.Load 事件处理程序。
C# | 复制代码 |
---|---|
using System; using System.Windows.Forms; using DevExpress.XtraCharts; // ... private void Form1_Load(object sender, EventArgs e) { // Create an empty chart. ChartControl PieChart3D = new ChartControl(); // Create a pie series. Series series1 = new Series("Pie Series 1", ViewType.Pie3D); // 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. PieChart3D.Series.Add(series1); // Adjust the value numeric options of the series. series1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; series1.PointOptions.ValueNumericOptions.Precision = 0; // Adjust the view-type-specific options of the series. ((Pie3DSeriesView)series1.View).Depth = 30; ((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[0]); ((Pie3DSeriesView)series1.View).ExplodedDistancePercentage = 30; // Access the diagram's options. ((SimpleDiagram3D)PieChart3D.Diagram).RotationType = RotationType.UseAngles; ((SimpleDiagram3D)PieChart3D.Diagram).RotationAngleX = -35; // Add a title to the chart and hide the legend. ChartTitle chartTitle1 = new ChartTitle(); chartTitle1.Text = "3D Pie Chart"; PieChart3D.Titles.Add(chartTitle1); PieChart3D.Legend.Visible = false; // Add the chart to the form. PieChart3D.Dock = DockStyle.Fill; this.Controls.Add(PieChart3D); } |
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 an empty chart. Dim PieChart3D As New ChartControl() ' Create a pie series. Dim series1 As New Series("Pie Series 1", ViewType.Pie3D) ' 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. PieChart3D.Series.Add(series1) ' Adjust the value numeric options of the series. series1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent series1.PointOptions.ValueNumericOptions.Precision = 0 ' Adjust the view-type-specific options of the series. CType(series1.View, Pie3DSeriesView).Depth = 30 CType(series1.View, Pie3DSeriesView).ExplodedPoints.Add(series1.Points(0)) CType(series1.View, Pie3DSeriesView).ExplodedDistancePercentage = 30 ' Access the diagram's options. CType(PieChart3D.Diagram, SimpleDiagram3D).RotationType = RotationType.UseAngles CType(PieChart3D.Diagram, SimpleDiagram3D).RotationAngleX = -35 ' Add a title to the chart and hide the legend. Dim chartTitle1 As New ChartTitle() chartTitle1.Text = "3D Pie Chart" PieChart3D.Titles.Add(chartTitle1) PieChart3D.Legend.Visible = False ' Add the chart to the form. PieChart3D.Dock = DockStyle.Fill Me.Controls.Add(PieChart3D) End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1028。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |