A stacked bar chart will stack all series right upon each other and to do so it expects data points for all x-values (*) of each series. So the gaps in your chart come from gaps in the data points.
To get the result you probably want:
you need to fill in all the missing points with values of 0. I have used a class daz
in a list points
instead of your items
, but you will get the 'point'..:
points.Add(new daz("0", 0, 3));
points.Add(new daz("0", 1, 0)); //<-filler
points.Add(new daz("0", 2, 0)); //<-filler
points.Add(new daz("1", 0, 7));
points.Add(new daz("1", 1, 0)); //<-filler
points.Add(new daz("1", 2, 0)); //<-filler
points.Add(new daz("2", 0, 1));
points.Add(new daz("2", 1, 0)); //<-filler
points.Add(new daz("2", 2, 0)); //<-filler
points.Add(new daz("3", 0, 1));
points.Add(new daz("3", 1, 7));
points.Add(new daz("3", 2, 0)); //<-filler
points.Add(new daz("4", 0, 0)); //<-filler
points.Add(new daz("4", 1, 3));
points.Add(new daz("4", 2, 0)); //<-filler
points.Add(new daz("5", 0, 0)); //<-filler
points.Add(new daz("5", 1, 1));
points.Add(new daz("5", 2, 0)); //<-filler
points.Add(new daz("6", 0, 0)); //<-filler
points.Add(new daz("6", 1, 1));
points.Add(new daz("6", 2, 2));
points.Add(new daz("7", 0, 0)); //<-filler
points.Add(new daz("7", 1, 1));
points.Add(new daz("7", 2, 3));
points.Add(new daz("8", 0, 0)); //<-filler
points.Add(new daz("8", 1, 0)); //<-filler
points.Add(new daz("8", 2, 2));
points.Add(new daz("9", 0, 0)); //<-filler
points.Add(new daz("9", 1, 0)); //<-filler
points.Add(new daz("9", 2, 3));
Depending on your data structure and source you should either do it when collecting the data or start out with a zero-pre-filled data structure or maybe use a little linq to fill in the gaps later..
(*) Note that x
and y
are switched visually in bar charts, so the x-axis
is vertical here!