Reputation: 307
I have two sets of array containing 7 objects, with values in one and dates on another.
I would like to generate a simple bar graph with date on x axis and values on y axis.
I searched google and ofcourse stackoverflow, but I didn't find a satisfactory answer.
In every answer, it's all about Coreplot, which I don't want to use because of it's complexity(Me being a begineer in ios development).
Is there any other way except, CorePlot to achieve such graph? Or Can someone provide me an example to plot using inbuilt apple API'S
Awaiting an answer, Thanks a lot in advance.
Upvotes: 1
Views: 3432
Reputation: 91
This third party project worked nice for me and I found the design much better than most other projects. Unfortunately is paid, but it's always an option :)
http://www.binpress.com/app/ios-bar-chart-view/1836
Upvotes: 0
Reputation: 307
I tried using coreplot, but it is a giant framework which is too good and toodifficult for a begineer like me to consume. So I came across OVGraph, which is a basic framework that does all I want, And it is easy to use as well,
something like this :
OVGraphView *graphview=[[OVGraphView alloc]initWithFrame:CGRectMake(0, 0, 480, 300) ContentSize:CGSizeMake(960, 300)];
//customizations go here
[self.view addSubview:graphview];
[graphview setPoints:@[[[OVGraphViewPoint alloc]initWithXLabel:@"today" YValue:@3.2 ],[[OVGraphViewPoint alloc]initWithXLabel:@"yesterday" YValue:@4 ],[[OVGraphViewPoint alloc]initWithXLabel:@"3" YValue:@6 ]]];
generates beautiful graphs.
Upvotes: 1
Reputation: 77661
You will need to do this inside a custom UIView.
In the drawRect method you can calculate the extent of the x-axis and the y-axis. You then need to draw the axes onto the actual screen with the numbers showing the values.
Then you need to work out how thick each bar should be and how tall they need to be.
Then draw them into their relevant spaces along the x-axis.
Before any of this though you need to give is a background colour. Maybe some guide lines so the user can easily read the values...
Or you can use http://www.cocoapods.org to install CorePlot and it will do it all for you.
It is MUCH MUCH MUCH MUCH more difficult to draw the graph yourself than it is sto spend a while learning how to use coreplot.
Upvotes: 1