Search code examples
ioscore-plotdiagrams

How to create non-stacked subbars chart using core-plot?


I need to display bar-chart diagram. The main issue I've not found yet is how to display bars with sub-bars. So the first bar consists of green bar (with 5 points for y) at bottom and yellow bar (with 3 points for y). And the second bar consists of pink bar at bottom (with 3 points for y)
So my bars are not stacked. - I can have even no bars for next x, but I can have 3 sub-bars in one bar in different order.

Generally the following image shows what bars do I need. Generally the following image shows what bars do I need.


Solution

  • Use a different bar plot for each fill pattern. Set barBasesVary to YES on each plot so you can control the ends of bars individually. The plot will query the datasource for three values for each bar: the location (the horizontal position for vertical bars), the tip (the top) value, and the base (the bottom) value. The "Vertical Bar Chart" demo in the Plot Gallery example app shows a simple example of this technique.