1

I have a dotnetcharting graph with 3 series. I can change the style of the whole graph to stacked.

ChartIn.YAxis.Scale = Scale.Stacked;

But I want to just stack two out of the three series. So that for each there are two bars combined into one stack with another whole bar next to it.

Can this be done?

Jeffrey Blake
  • 9,659
  • 6
  • 43
  • 65
Hoody
  • 3,361
  • 9
  • 45
  • 55

2 Answers2

1

In the end I made the data I wanted separated from the stack into a separate filled line series. Not ideal but it looked fine.

ChartThree.SeriesCollection[3].Type = SeriesType.AreaLine;
Hoody
  • 3,361
  • 9
  • 45
  • 55
0

The way to accomplish this is by creating an additional scale and setting the extra series's YAxis to that scale. The second scale can be stacked independently of whether or not the first scale is stacked. Note that you will need to adjust the ranges on the second scale in order to make the values show up in the correct relative size.

Here's an example that produces a chart with two separately stacked sets of data (using a chart that has previously been populated with a total of 4 series):

//set main chart to stacked
Chart.YAxis.Scale = Scale.Stacked; 

//create new axis, assign it to relevant series, and set it's scale to stacked
Axis a2 = new Axis();
Chart.SeriesCollection[2].YAxis = a2;
Chart.SeriesCollection[3].YAxis = a2;
a2.Scale = Scale.Stacked;

//tie the scales together to ensure proper relative display
Chart.YAxis.SynchronizeScale.Add(a2);
Jeffrey Blake
  • 9,659
  • 6
  • 43
  • 65