Xceed Chart for WinForms v4.4 Documentation
Stacked Percent Line

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Series > XY Scatter Series > Line Series > Stacked Percent Line

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



figure 1.

Creating the Stacked Percent Line Series

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

VB.NET  

' there is one chart created by default

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

 

Dim line1 As LineSeries = CType(Chart.Series.Add(SeriesType.Line), LineSeries)

Dim line2 As LineSeries = CType(Chart.Series.Add(SeriesType.Line), LineSeries)

Dim line3 As LineSeries = CType(Chart.Series.Add(SeriesType.Line), LineSeries)

 

line1.MultiLineMode = MultiLineMode.Series

 

line2.MultiLineMode = MultiLineMode.StackedPercent

line3.MultiLineMode = MultiLineMode.StackedPercent

C#  
// there is one chart created by default
Chart chart = (Chart)chartControl1.Charts[0];
LineSeries line1 = (LineSeries)Chart.Series.Add(SeriesType.Line);
LineSeries line2 = (LineSeries)Chart.Series.Add(SeriesType.Line);
LineSeries line3 = (LineSeries)Chart.Series.Add(SeriesType.Line);
line1.MultiLineMode = MultiLineMode.Series;
line2.MultiLineMode = MultiLineMode.StackedPercent;
line3.MultiLineMode = MultiLineMode.StackedPercent;

Stacked Percent Line Scaling

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

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

Stacked Percent Line Charts with negative values

Stacked percent line charts do not support negative values, which means that all values are internally converted to their absolute value.

Stacked Percent Line Chart Formatting Commands

The following formatting commands inherited from the Series class have different meanings when a line 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\Line\Stacked Line

See Also

LineSeries