简要说明
簇状百分比堆积条形图 是由 SideBySideFullStackedBar3DSeriesView 对象来表示的,此对象属于 条形和柱状系列视图。 这种视图结合了 百分比堆积条形图 和 簇状条形图 两种图表类型的优点,因此可以堆积不同的条形,并把它们组合为跨相同的轴取值而并排显示的多个组 (通过 SideBySideFullStackedBar3DSeriesView.StackedGroup 属性)。
注意 |
---|
当使用 系列模板构建 簇状百分比堆积条形图时,应在运行时刻指定 SideBySideFullStackedBar3DSeriesView.StackedGroup 属性 (在 ChartControl.BoundDataChanged 事件处理程序中指定)。 |
在下面的插图中显示了一个簇状百分比堆积条形图。
注意 |
---|
簇状百分比堆积条形图可以显示包含正值或负值数据点的系列。 但是,有正值的系列只能与其他包含正值的系列相堆积; 有负值的系列与其他包含负值的系列相堆积。 注意,如果系列同时包含正值和负值数据点,那么它被作为有正值的系列进行处理,而它的所有负值都被视为零。 |
图表类型特征
下表列出了这种图表类型的主要特征。
特征 |
取值 |
---|---|
系列视图类型 | SideBySideFullStackedBar3DSeriesView |
图象类型 | XYDiagram3D |
每个数据点的参数个数 | 1 |
每个数据点的取值个数 | 1 |
注意 |
---|
要获得关于哪些图表类型可以与 簇状百分比堆积条形图 组合使用的信息,请参阅 组合使用不同的系列视图 文档。 |
示例
这个示例展示了在运行时刻如何创建一个有 SideBySideFullStackedBar3DSeriesView 类型的系列的图表,并把图表添加到窗体中。 在继续本示例之前,首先要在 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 stackedBarChart = new ChartControl(); // Create four side-by-side full-stacked bar series. Series series1 = new Series("Series 1", ViewType.SideBySideFullStackedBar3D); Series series2 = new Series("Series 2", ViewType.SideBySideFullStackedBar3D); Series series3 = new Series("Series 3", ViewType.SideBySideFullStackedBar3D); Series series4 = new Series("Series 4", ViewType.SideBySideFullStackedBar3D); // Add points to them series1.Points.Add(new SeriesPoint("A", 10)); series1.Points.Add(new SeriesPoint("B", 12)); series1.Points.Add(new SeriesPoint("C", 14)); series1.Points.Add(new SeriesPoint("D", 17)); series2.Points.Add(new SeriesPoint("A", 5)); series2.Points.Add(new SeriesPoint("B", 8)); series2.Points.Add(new SeriesPoint("C", 5)); series2.Points.Add(new SeriesPoint("D", 3)); series3.Points.Add(new SeriesPoint("A", 11)); series3.Points.Add(new SeriesPoint("B", 13)); series3.Points.Add(new SeriesPoint("C", 15)); series3.Points.Add(new SeriesPoint("D", 18)); series4.Points.Add(new SeriesPoint("A", 6)); series4.Points.Add(new SeriesPoint("B", 9)); series4.Points.Add(new SeriesPoint("C", 6)); series4.Points.Add(new SeriesPoint("D", 4)); // Add all series to the chart. stackedBarChart.Series.AddRange (new Series[] { series1, series2, series3, series4 }); // Group the first two series under the same stack. ((SideBySideFullStackedBar3DSeriesView)series1.View).StackedGroup = 0; ((SideBySideFullStackedBar3DSeriesView)series2.View).StackedGroup = 0; // Access the type-specific options of the diagram. ((XYDiagram3D)stackedBarChart.Diagram).RuntimeZooming = true; // Hide the legend (if necessary). stackedBarChart.Legend.Visible = false; // Add a title to the chart (if necessary). stackedBarChart.Titles.Add(new ChartTitle()); stackedBarChart.Titles[0].Text = "A 3D Side-By-Side Full-Stacked Bar Chart"; stackedBarChart.Titles[0].WordWrap = true; // Add the chart to the form. stackedBarChart.Dock = DockStyle.Fill; this.Controls.Add(stackedBarChart); } |
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 stackedBarChart As New ChartControl() ' Create four side-by-side full-stacked bar series. Dim series1 As New Series("Series 1", ViewType.SideBySideFullStackedBar3D) Dim series2 As New Series("Series 2", ViewType.SideBySideFullStackedBar3D) Dim series3 As New Series("Series 3", ViewType.SideBySideFullStackedBar3D) Dim series4 As New Series("Series 4", ViewType.SideBySideFullStackedBar3D) ' Add points to them series1.Points.Add(New SeriesPoint("A", 10)) series1.Points.Add(New SeriesPoint("B", 12)) series1.Points.Add(New SeriesPoint("C", 14)) series1.Points.Add(New SeriesPoint("D", 17)) series2.Points.Add(New SeriesPoint("A", 5)) series2.Points.Add(New SeriesPoint("B", 8)) series2.Points.Add(New SeriesPoint("C", 5)) series2.Points.Add(New SeriesPoint("D", 3)) series3.Points.Add(New SeriesPoint("A", 11)) series3.Points.Add(New SeriesPoint("B", 13)) series3.Points.Add(New SeriesPoint("C", 15)) series3.Points.Add(New SeriesPoint("D", 18)) series4.Points.Add(New SeriesPoint("A", 6)) series4.Points.Add(New SeriesPoint("B", 9)) series4.Points.Add(New SeriesPoint("C", 6)) series4.Points.Add(New SeriesPoint("D", 4)) ' Add all series to the chart. stackedBarChart.Series.AddRange (New Series() { series1, series2, series3, series4 }) ' Group the first two series under the same stack. CType(series1.View, SideBySideFullStackedBar3DSeriesView).StackedGroup = 0 CType(series2.View, SideBySideFullStackedBar3DSeriesView).StackedGroup = 0 ' Access the type-specific options of the diagram. CType(stackedBarChart.Diagram, XYDiagram3D).RuntimeZooming = True ' Hide the legend (if necessary). stackedBarChart.Legend.Visible = False ' Add a title to the chart (if necessary). stackedBarChart.Titles.Add(New ChartTitle()) stackedBarChart.Titles(0).Text = "A 3D Side-By-Side Full-Stacked Bar Chart" stackedBarChart.Titles(0).WordWrap = True ' Add the chart to the form. stackedBarChart.Dock = DockStyle.Fill Me.Controls.Add(stackedBarChart) End Sub |
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E2182。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |