Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Draw Stacked Bar Graphs in iOS

I want to draw Stack Bar Graph in iOS application in the given link

http://peltiertech.com/images/2009-05/StackChart4.png

.I Know to draw Simple Bar Graphs using core plot,but could not find a way to draw Stacked Bar Graphs.Please Can anyone suggest me the way to draw Stacked Bar Graphs using core plot or any other libraries.Please suggest any other libraries available to draw this in iOS application.

like image 452
Himanshu Khatri Avatar asked Jan 20 '12 12:01

Himanshu Khatri


Video Answer


1 Answers

Core Plot won't do the stacking calculations for you, but it can draw the bars. You'll need one bar plot for each data series. For example, you could draw one bar from 0 to 2 with one plot. The next plot could have a bar that spans between 2 and 5 and a third plot could go between 5 and 6.

The way to set this up is to set barBasesVary = YES for all but the bottom plot in the stack. These plots will ask the datasource for an additional plot field called CPTBarPlotFieldBarBase. Use that to set the starting value for the bar and use CPTBarPlotFieldBarTip to set the end point as usual.

like image 87
Eric Skroch Avatar answered Sep 21 '22 18:09

Eric Skroch