Problem with stacked bars
Posted: Wed Aug 24, 2016 9:02 am
Hi,
I am trying to draw a stacked bars chart but I am facing some issues.
This is what I would like to achieve: I have, let's say, 3 stacks bars. So I would like 3 stacks in the chart. Each stack is composed of 4 values, all these values sum up 100%. So I have 3 stacks, with 4 values per stack. Also, the legend box should have 3 entries, one per stack.
I have tried different approaches:
- Create 3 BarSeries, each of which containing 4 BarSeriesValue, and grouping ByLocation. So each BarSeries will use a different location value for its BarSeriesValues. This way I can see 3 stacks in the chart, but only the first BarSeriesValue is shown, instead of 4.
- Create 3 BarSeries, each of which containing 4 BarSeries, each of which containing 1 BarSeriesValue. Grouping the same way as above. This way I can see the bars correctly, 3 bars each of which containing 4 elements. But there are 3x4 elements in the legend box.
- Group ByIndex. This way it seems to use the BarSeriesValue index to decide in which stack the block goes. I find this way of grouping confusing, as the elements of a BarSeries are displayed in different stacks, so they end up displayed horizontally instead of stacked. I guess I could use 3 different indices (1 per stack), and 4 BarSeries, each of which containing these 3 BarSeriesValues. But the legend instead of showing the names of what I want in the stacks, would show the name of the possible values in the stacks.
Am I missing anything about how stacked bars work? Is there a better way of doing what I try to achieve?
Thanks
I am trying to draw a stacked bars chart but I am facing some issues.
This is what I would like to achieve: I have, let's say, 3 stacks bars. So I would like 3 stacks in the chart. Each stack is composed of 4 values, all these values sum up 100%. So I have 3 stacks, with 4 values per stack. Also, the legend box should have 3 entries, one per stack.
I have tried different approaches:
- Create 3 BarSeries, each of which containing 4 BarSeriesValue, and grouping ByLocation. So each BarSeries will use a different location value for its BarSeriesValues. This way I can see 3 stacks in the chart, but only the first BarSeriesValue is shown, instead of 4.
- Create 3 BarSeries, each of which containing 4 BarSeries, each of which containing 1 BarSeriesValue. Grouping the same way as above. This way I can see the bars correctly, 3 bars each of which containing 4 elements. But there are 3x4 elements in the legend box.
- Group ByIndex. This way it seems to use the BarSeriesValue index to decide in which stack the block goes. I find this way of grouping confusing, as the elements of a BarSeries are displayed in different stacks, so they end up displayed horizontally instead of stacked. I guess I could use 3 different indices (1 per stack), and 4 BarSeries, each of which containing these 3 BarSeriesValues. But the legend instead of showing the names of what I want in the stacks, would show the name of the possible values in the stacks.
Am I missing anything about how stacked bars work? Is there a better way of doing what I try to achieve?
Thanks