How to: Simple graph?

Discussion in 'iOS Programming' started by MTShipp, Jun 6, 2009.

  1. MTShipp macrumors 6502a

    Joined:
    Mar 25, 2009
    Location:
    Raleigh, North Carolina
    #1
    I am trying to figure out how to draw a simple trending graph. I do not need anything fancy. Just some whole number points over a short period of time. I have the 'Beginning iPhone Development' book but that is not shown in the chapters. Can someone tell me where to find info on that? If it is in the SDK, please tell me how to find it.
     
  2. Niiro13 macrumors 68000

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #2
    Unless I am mistaken, you'd have to draw the graphs yourself using Quartz 2D functions

    Example:
    PHP:
     CGContextRef context UIGraphicsGetCurrentContext();
        
    CGContextSetStrokeColorWithColor(context, [[UIColor blackColorCGColor]);
        
    CGContextBeginPath(context);
        
    CGContextMoveToPoint(context20.0f40.0f);
        
    CGContextAddLineToPoint(context20.0f210.0f);
        
    CGContextAddLineToPoint(context210.0f210.0f);
        
    CGContextStrokePath(context);
    That will get you the axis line for both the x and the y (yeah, a lot for just two lines >_<).

    At least that's what I believe you have to do.
     
  3. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #3
    There's example graphing code in Apple's Accelerometer sample app, available on their dev site.
     

Share This Page