Articles in this section
Category / Section

How to group stacking series in the Blazor Chart?

5 mins read

This article explains how to group the stacking series in the Blazor Chart.

Grouping stacking series in Blazor Chart

Stacking series are rendered in such a way that all the series are stacked. This is not desired when there are many stacking series in the chart. In such cases, the Blazor Chart provides options to group the stacking series by using StackingGroup property.

For example, consider four stacking column series grouped into two; Group1 and Group2 by using the StackingGroup property. Then, chart is rendered in two stacking columns at a point; one for Group1 and the other for Group2.

The following code example demonstrates how to group the stacking series in Blazor Chart.

Index.razor



@using Syncfusion.Blazor.Charts

<sfchart>

    <chartprimaryxaxis valuetype="Syncfusion.Blazor.Charts.ValueType.Category"></chartprimaryxaxis>

    <chartseriescollection>
        <chartseries datasource="@DataSource" stackinggroup="Group1" xname="X" yname="YValue" type="ChartSeriesType.StackingColumn">
        </chartseries>
        <chartseries datasource="@DataSource" stackinggroup="Group1" xname="X" yname="YValue1" type="ChartSeriesType.StackingColumn">
        </chartseries>
        <chartseries datasource="@DataSource" stackinggroup="Group2" xname="X" yname="YValue2" type="ChartSeriesType.StackingColumn">
        </chartseries>
        <chartseries datasource="@DataSource" stackinggroup="Group2" xname="X" yname="YValue3" type="ChartSeriesType.StackingColumn">
        </chartseries>
    </chartseriescollection>

</sfchart>

@code {

    public class ChartData
    {
        public string X { get; set; }
        public double YValue { get; set; }
        public double YValue1 { get; set; }
        public double YValue2 { get; set; }
        public double YValue3 { get; set; }
    }

    public List<chartdata> DataSource = new List<chartdata>
    {
        new ChartData { X= "USA", YValue= 46, YValue1=56, YValue2=26,YValue3=50},
        new ChartData { X= "GBR", YValue= 27, YValue1=17, YValue2=37,YValue3=20},
        new ChartData { X= "CHN", YValue= 26, YValue1=36, YValue2=56,YValue3=26},
        new ChartData { X= "UK", YValue= 56,  YValue1=16, YValue2=36,YValue3=16},
        new ChartData { X= "AUS", YValue= 12, YValue1=46, YValue2=26,YValue3=20},
        new ChartData { X= "IND", YValue= 26, YValue1=16, YValue2=76,YValue3=25},
        new ChartData { X= "DEN", YValue= 26, YValue1=12, YValue2=42,YValue3=20},
        new ChartData { X= "MEX", YValue= 34, YValue1=32, YValue2=82,YValue3=35},
    };
}

The following screenshot illustrate the output of the above code snippet.

Output:

Figure 1:- Before Grouping

before_grouping.png

Figure 2:- After Grouping

stacking_group.png

View the sample in GitHub

Conclusion

I hope you enjoyed learning how to group the Stacking series in Blazor Chart Component.

You can refer to our Blazor Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Chart example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied