Plotting graph on iphone

Discussion in 'iPhone/iPad Programming' started by arnieterm, Oct 19, 2009.

  1. macrumors regular

    Joined:
    Aug 28, 2008
    #1
    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. macrumors 6502

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

    Joined:
    Aug 28, 2008
    #3
    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
    Thanks
    Arnieterm
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    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. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #5
    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