ComponentOne FlexChart for WinForms
Stacked Groups
FlexChart > Working with FlexChart > FlexChart Elements > Series > Stacked Groups

FlexChart supports stacking and grouping of data items in column and bar charts. Stacking provides capabilities for stacking data items one on top of the other (in column chart) or side-by-side (in bar chart). Whereas, grouping enables clustering of the stacked data items in bar and column charts.  

Stacked groups allow you to compare items across categories in a group. In addition, you can visualize relative difference between items in each group.

The following image displays stacked groups in FlexChart.

To stack specific series in a specific stacked group, set the index value of that stacked group in the StackingGroup property for the series. Note that Stacked groups in FlexChart are implementable when the Stacking property for FlexChart is set to either Stacked or Stacked100pc, which specifies how the data values of chart will be stacked.

The following code compares fruit data for three consecutive months and shows how to implement stacked groups in FlexChart.

FlexChart1.Series.Clear()

' Add three data series
Dim s1 = New Series()
s1.Binding = "March"
s1.Name = "March"
FlexChart1.Series.Add(s1)

Dim s2 = New Series()
s2.Binding = "April"
s2.Name = "April"
FlexChart1.Series.Add(s2)

Dim s3 = New Series()
s3.Binding = "May"
s3.Name = "May"
FlexChart1.Series.Add(s3)

' Set x-binding and add data to the chart
FlexChart1.BindingX = "Fruit"
FlexChart1.DataSource = DataCreator.CreateFruit()

' set FlexChart stacking type
FlexChart1.Stacking = C1.Chart.Stacking.Stacked

' specify stacking group for each series
FlexChart1.Series(0).StackingGroup = 0
FlexChart1.Series(1).StackingGroup = 0
FlexChart1.Series(2).StackingGroup = 1
flexChart1.Series.Clear();

// Add three data series
var s1 = new Series();
s1.Binding = s1.Name = "March";
flexChart1.Series.Add(s1);

var s2 = new Series();
s2.Binding = s2.Name = "April";
flexChart1.Series.Add(s2);

var s3 = new Series();
s3.Binding = s3.Name = "May";
flexChart1.Series.Add(s3);

// Set x-binding and add data to the chart
flexChart1.BindingX = "Fruit";
flexChart1.DataSource = DataCreator.CreateFruit();

// set FlexChart stacking type
flexChart1.Stacking = C1.Chart.Stacking.Stacked100pc;

// specify stacking group for each series
flexChart1.Series[0].StackingGroup = 0;
flexChart1.Series[1].StackingGroup = 0;
flexChart1.Series[2].StackingGroup = 1;
See Also