Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing a simple graph on the iPhone

Does anyone know of any existing code that will draw a graph for me in my iPhone application? I just need a simple line graph without labels or a title or even axis labels for the data.

Or does anyone have ideas about where to start so that I can learn how to draw such a thing? I've never dealt with actual graphics for the iPhone. All my applications are just image based until now.

Thanks!

like image 472
CodeGuy Avatar asked Dec 30 '10 14:12

CodeGuy


People also ask

Can I make a graph on my iPhone?

In Numbers, graphs are created using data from a table. To create any type of graph, you can select the data first, then create a graph that displays the data. When you change the data in the table, the graph updates automatically.

Is there an app to make a graph?

Canva is a popular app which lets users to create graphs or charts with tables, photos and graphics in minutes. All you have to do is enter your data to get instant results. Canva offers a range of free, designer-made templates.


2 Answers

Try out the Core Plot framework http://code.google.com/p/core-plot/

like image 148
Jasarien Avatar answered Sep 20 '22 10:09

Jasarien


If you would attempt to draw yourself, you'd use the Path functions to draw in a context in Quartz

CGContextBeginPath(context);
CGContextMoveToPoint(context, startX, startY);
CGContextAddLineToPoint(context, nextX, nextY);
// [...] and so on, for all line segments
CGContextSetLineWidth(context, 2);
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] cgColor]);
CGContextStrokePath(context);

There is a lot of sample code to deal with context and drawing in quartz.

But there are probably some libraries to facilitate drawing graphs... someone else would have to help you with those though, not my cup of tea :)

like image 21
Pieter Avatar answered Sep 20 '22 10:09

Pieter