The Stacked Bar Chart is represented by the StackedBarSeriesView object, which belongs to Bar Series Views. This view displays all the points of its series. Series values are stacked at arguments included in multiple series. So, the height of each bar is determined by the total of all the series values for the category. So, the height of each bar is determined by the total of all the series values for the category.
A Stacked Bar chart is shown in the image below. Note that this chart type is based upon the XYDiagram, and so it can be rotated to show bars either vertically or horizontally.

The table below lists the main characteristics of this chart type.
Feature |
Value |
Series View type |
StackedBarSeriesView |
Diagram type |
2D-XYDiagram |
Number of arguments per series point |
1 |
Number of values per series point |
1 |
Note
For information on which chart types can be combined with the Stacked Bar Chart, refer to the Series Views Compatibility document.
The following example demonstrates how to create a ChartControl with two series of the StackedBarSeriesView type, and add this chart to a form at runtime. Before proceeding with this example, first create a Windows Forms Application in Visual Studio, and include all necessary assemblies to the References list of your project.
Then, add the following code to the Form.Load event handler.
C# |
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
private void Form1_Load(object sender, EventArgs e) {
ChartControl stackedBarChart = new ChartControl();
Series series1 = new Series("Series 1", ViewType.StackedBar);
Series series2 = new Series("Series 2", ViewType.StackedBar);
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", 15));
series2.Points.Add(new SeriesPoint("B", 18));
series2.Points.Add(new SeriesPoint("C", 25));
series2.Points.Add(new SeriesPoint("D", 33));
stackedBarChart.Series.AddRange(new Series[] { series1, series2 });
((StackedBarSeriesView)series1.View).BarWidth = 0.8;
((XYDiagram)stackedBarChart.Diagram).EnableAxisXZooming = true;
stackedBarChart.Legend.Visible = false;
stackedBarChart.Titles.Add(new ChartTitle());
stackedBarChart.Titles[0].Text = "A Stacked Bar Chart";
stackedBarChart.Dock = DockStyle.Fill;
this.Controls.Add(stackedBarChart);
}
|
VB |
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles MyBase.Load
Dim stackedBarChart As New ChartControl()
Dim series1 As New Series("Series 1", ViewType.StackedBar)
Dim series2 As New Series("Series 2", ViewType.StackedBar)
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", 15))
series2.Points.Add(New SeriesPoint("B", 18))
series2.Points.Add(New SeriesPoint("C", 25))
series2.Points.Add(New SeriesPoint("D", 33))
stackedBarChart.Series.AddRange(New Series() { series1, series2 })
CType(series1.View, StackedBarSeriesView).BarWidth = 0.8
CType(stackedBarChart.Diagram, XYDiagram).EnableAxisXZooming = True
stackedBarChart.Legend.Visible = False
stackedBarChart.Titles.Add(New ChartTitle())
stackedBarChart.Titles(0).Text = "A Stacked Bar Chart"
stackedBarChart.Dock = DockStyle.Fill
Me.Controls.Add(stackedBarChart)
End Sub
|