Chart for .NET / User's Guide / Chart Types / Bar / Cluster Stack Combinations

In This Topic
    Cluster Stack Combinations
    In This Topic

    Nevron Chart for .NET can display cluster stack combination bar charts. The following figure demonstrates a typical chart of this class:




    Figure 1.

     Creating the bar series

    The following code will create the bar series involved in this chart:

    C#
    Copy Code
    // obtain a reference to the Cartesian chart that is created by default
    NCartesianChart chart = (NCartesianChart)chartControl.Charts[0];
    
    // first cluster
    NBarSeries c1bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
    NBarSeries c1bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
    c1bar1.MultiBarMode = MultiBarMode.Series;
    c1bar2.MultiBarMode = MultiBarMode.Stacked;
    
    // second cluster
    NBarSeries c2bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
    NBarSeries c2bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
    NBarSeries c2bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
    c2bar1.MultiBarMode = MultiBarMode.Clustered; // display next to c1bar1
    c2bar2.MultiBarMode = MultiBarMode.Stacked;   // stack on c2bar1
    c2bar3.MultiBarMode = MultiBarMode.Stacked;   // stack on c2bar2
    
    Visual Basic
    Copy Code
    ' obtain a reference to the Cartesian chart that is created by default
    Dim chart As NCartesianChart = chartControl.Charts(0)
    
    ' first cluster
    Dim c1bar1 As NBarSeries = chart.Series.Add(SeriesType.Bar)
    Dim c1bar2 As NBarSeries = chart.Series.Add(SeriesType.Bar)
    c1bar1.MultiBarMode = MultiBarMode.Series
    c1bar2.MultiBarMode = MultiBarMode.Stacked
    
    ' second cluster
    Dim c2bar1 As NBarSeries = chart.Series.Add(SeriesType.Bar)
    Dim c2bar2 As NBarSeries = chart.Series.Add(SeriesType.Bar)
    Dim c2bar3 As NBarSeries = chart.Series.Add(SeriesType.Bar)
    c2bar1.MultiBarMode = MultiBarMode.Clustered ' display next to c1bar1
    c2bar2.MultiBarMode = MultiBarMode.Stacked   ' stack on c2bar1
    c2bar3.MultiBarMode = MultiBarMode.Stacked   ' stack on c2bar2
    

    As you can see from the code above the component uses a simple technique to specify the position of the bar series. If a series MultiBarMode is set to Clustered it forms a cluster with the previous series or group of series. In the context of the example c2bar1 is displayed next to the stack formed by c1bar1 and c1bar2.

    If a series MultiBarMode is set to Stacked or StackedPercent it is stacked on the previous bar series with Clustered mode or in case such series does not exist to the previous bar series with mode Series. Multiple bar series can be stacked on a bar series with mode Clustered or Series. The type of stacking (stacked or stacked percent) is determined by the last series in the stack.

     Related Examples
    Windows forms: Chart Gallery\Bar\Cluster Stack Combination
    See Also