Xceed Chart for WinForms v4.4 Documentation
Stacked Percent Bar

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Series > Bar Series > Stacked Percent Bar

Stacked percent bars are created by using several instances of the BarSeries class. The first bar series created must have its MultiBarMode property set to MultiBarMode.Series. The MultiBarMode property of the subsequent bar series must be set to MultiBarMode.StackedPercent. Stacked percent bar series are displayed on top of each other, and all stacks begin at 0 and end at 1. The following figure shows a typical stack percent bar chart: 



figure 1.

Creating the Stacked Percent Bar Series

The following example demonstrates how to create a stacked percent bar chart with three stacks:

VB.NET  

' there is one chart created by default

Dim chart As Chart = CType(chartControl1.Charts(0), Chart)

 

Dim bar1 As BarSeries = CType(chart.Series.Add(SeriesType.Bar), BarSeries)

Dim bar2 As BarSeries = CType(chart.Series.Add(SeriesType.Bar), BarSeries)

Dim bar3 As BarSeries = CType(chart.Series.Add(SeriesType.Bar), BarSeries)

 

bar1.MultiBarMode = MultiBarMode.Series

bar2.MultiBarMode = MultiBarMode.StackedPercent

bar3.MultiBarMode = MultiBarMode.StackedPercent

C#  
// there is one chart created by default
Chart chart = (Chart)chartControl1.Charts[0];
BarSeries bar1 = (BarSeries)chart.Series.Add(SeriesType.Bar);
BarSeries bar2 = (BarSeries)chart.Series.Add(SeriesType.Bar);
BarSeries bar3 = (BarSeries)chart.Series.Add(SeriesType.Bar);
bar1.MultiBarMode = MultiBarMode.Series;
bar2.MultiBarMode = MultiBarMode.StackedPercent;
bar3.MultiBarMode = MultiBarMode.StackedPercent;

Stacked Percent Scaling

When a bar series is displayed in stacked percent mode, the min value of the series is always 0 and max value of the series is always 1. In order to display the texts on the PrimaryY axis as a percentage, you must use the following code:

VB.NET  
chart.Axis(StandardAxis.PrimaryY).ValueFormat.Format = ValueFormat.Percentage
C#  
chart.Axis(StandardAxis.PrimaryY).ValueFormat.Format = ValueFormat.Percentage;

Stacks with Negative Values

Stacked percent bar charts do not support negative values, meaning that all values are internally converted to their absolute value.

Stacked Percent Bar Formatting Commands

The following formatting commands inherited from the Series class have different meanings when a bar series is stacked:

<total> - Displays the absolute sum of the values in the current stack.
<cumulative> - Displays the sum of the values up to the current stack value.
<percent> - Displays the percent contribution of the value to the total pile sum.

Related Examples

Windows Forms: Series\Bar\Stacked Bar

See Also

BarSeries