Plotting graph on iphone

Discussion in 'iOS Programming' started by arnieterm, Oct 19, 2009.

  1. arnieterm macrumors regular

    Aug 28, 2008
    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
  2. North Bronson macrumors 6502

    Oct 31, 2007
    San José
    If you need help using Core Graphics to plot a line graph, take a look at the "Accessibility" Apple sample code.
  3. arnieterm thread starter macrumors regular

    Aug 28, 2008
    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
  4. robbieduncan Moderator emeritus


    Jul 24, 2002
    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?
  5. firewood macrumors 604

    Jul 29, 2003
    Silicon Valley
    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.

Share This Page