View Full Version : Plotting graph on iphone
Oct 19, 2009, 10:12 AM
Using CGContext functions, I am trying to plot a line graph for a particular month. In the graph we have weekdays on x-axis and respective data on y-axis. I have to plot this graph for several month in such a way that all the graphs appears inside a scrollview so that the user can scroll them.
All this requires use of CGContext method so before going into it deeply I would like to know what effect it will have on application performance?
As plotting line graph is very urgent
Oct 19, 2009, 04:38 PM
If you need help using Core Graphics to plot a line graph, take a look at the "Accessibility" Apple sample code.
Oct 21, 2009, 05:02 AM
I have already created about 80% of chart. My only point of worry is as I have to show a scrollview containing UIViews on which these charts are being plooted [Each UIView will have one chart on it]. Will it cause any performance related problem as I have to create chart for each month of the year. Though I think of limiting the number of pages [UIViews with charts] to some fixed count when that count exceeds then remove those UIViews and add another set of UIViews to the scrollview. Usig a lot of CGContext methods in drawRect of UIView will cause any performance problem that is my point of worry
Oct 21, 2009, 05:52 AM
Let me get this straight. Every time you are asked to draw any part of any of these charts you draw the whole thing again? Why not cache the drawing into an image and only redraw if the underlying data changes?
Oct 21, 2009, 09:33 AM
Why not draw only the month that's currently visible?
Look at the Accelerometer example for code that redraws 3 graphs in near real time, every frame.