Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dgdosen

macrumors 68030
Original poster
Dec 13, 2003
2,858
1,497
Seattle
Anyone know if there's anything in the SDK about how to draw a simple 2D graph? Kind of like the Stocks Applet uses?

Any push in the right direction would be greatly appreciated...
 
The basic idea is that it's an NSBezierPath that you add a whole bunch of points to like so:
Code:
NSBezierPath * myPath = [NSBezierPath bezierPath];
[myPath moveToPoint:NSMakePoint(0,0)];  //the starting point
[myPath lineToPoint:NSMakePoint(0,1)];
[myPath lineToPoint:NSMakePint(1,1)];
... etc...
[myPath stroke];
[myPath release];
 
Anyone have sample code that mimics the stock application graphing? That's pretty clean...
 
Kinda off topic but I sure wish they'd bring out a graphing calculator like the TI ones. :D
 
The basic idea is that it's an NSBezierPath that you add a whole bunch of points to like so:
Code:
NSBezierPath * myPath = [NSBezierPath bezierPath];
[myPath moveToPoint:NSMakePoint(0,0)];  //the starting point
[myPath lineToPoint:NSMakePoint(0,1)];
[myPath lineToPoint:NSMakePint(1,1)];
... etc...
[myPath stroke];
[myPath release];

NSBezierPath does not exist on the iPhone platform. I believe the way to do drawing like that is with CoreGraphics and a CGPath.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.