iPhone Tapku Graph, how can I use dates instead on numbers? -
i've found tapku graph http://duivesteyn.net/2010/03/07/iphone-sdk-implementing-the-tapku-graph-in-your-application/?utm_source=twitterfeed&utm_medium=twitter
... looks cool , simple implement
- (void) thread{ nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; srand([[nsdate date] timeintervalsince1970]); for(int i=0;i<100;i++){ //int no = rand() % 100 + i; int no = 10 + i; //i've changed above value prove heres //where supply data graphpoint *gp = [[graphpoint alloc] initwithid:i value:[nsnumber numberwithfloat:no]]; [data addobject:gp]; [gp release]; } //heres data drawn - (void) drawxaxislabelswithcontext:(cgcontextref) context{
however i'd have dates on horizontal axis instead of numbers...
any ideas?
looking @ source no github, line 293 of graphview.m sets x axis labels string specified each point on graph :
lab.text = [d xlabel];
so display dates, i'd implement tkgraphviewpoint protocol :
-(nsstring *)xlabel { nsdateformatter *formatter = [[[nsdateformatter alloc] init] autorelease]; [formatter setdateformat:@"eee, mmm d, yyyy"]; // i.e. wed, july 10, 2010 return [formatter stringfromdate:mydate]; }
(assuming graphpoint has nsdata *mydate property :)
the date formatting string options can found here.
Comments
Post a Comment