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 | |
---|---|
|
C# | |
---|---|
// there is one chart created by default LineSeries line1 = (LineSeries)Chart.Series.Add(SeriesType.Line); line1.MultiLineMode = MultiLineMode.Series; |
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