Stacked Bar charts are displayed with several NBarSeries objects. The MultiBarMode property of the first bar series must be set to MultiBarMode.Series. The MultiBarMode property of the subsequent bar series must be set to MultiBarMode.Stacked. The following example demonstrates how to create a stack bar chart with two stacks:
C# |
Copy Code
|
---|---|
// obtain a reference to the Cartesian chart that is created by default
NCartesianChart chart = (NCartesianChart)chartControl.Charts[0];
NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar1.MultiBarMode = MultiBarMode.Series;
bar2.MultiBarMode = MultiBarMode.Stacked;
|
Visual Basic |
Copy Code
|
---|---|
' obtain a reference to the Cartesian chart that is created by default Dim chart As NCartesianChart = chartControl.Charts(0) Dim bar1 As NBarSeries = chart.Series.Add(SeriesType.Bar) Dim bar2 As NBarSeries = chart.Series.Add(SeriesType.Bar) bar1.MultiBarMode = MultiBarMode.Series bar2.MultiBarMode = MultiBarMode.Stacked |
If you want to create a second stacked bar with two stacks behind the stack bar created in the previous sample you have to add the following code:
C# |
Copy Code
|
---|---|
NBarSeries bar4 = (NBarSeries)chart.Series.Add(SeriesType.Bar); NBarSeries bar5 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar4.MultiBarMode = MultiBarMode.Series; bar5.MultiBarMode = MultiBarMode.Stacked; |
Visual Basic |
Copy Code
|
---|---|
Dim bar4 As NBarSeries = chart.Series.Add(SeriesType.Bar) Dim bar5 As NBarSeries = chart.Series.Add(SeriesType.Bar) bar4.MultiBarMode = MultiBarMode.Series bar5.MultiBarMode = MultiBarMode.Stacked |