I would like to draw an XY plot using coreplot on an iphone with a date on the x axis and some values on the y axis. Referring to the DatePlot example sent with the coreplot SDK, I was able to draw a graph with a date along the x axis on a monthly scale (i.e., X varies from 1 date of the month to the last date). Now I want the annual scale, that is, I want to show all the monthly names (January, February, March, etc.) along the x axis, and my tick is one month.
I used the following code to display the values in the monthly scale
oneXUnit = 60 * 60 * 24;
x.majorIntervalLength = CPDecimalFromFloat((float) oneXUnit);
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]autorelease];
NSString *dateString = @"0";
[dateFormatter setDateFormat:@"MM"];
CPTimeFormatter *timeFormatter = [[CPTimeFormatter alloc]initWithDateFormatter:dateFormatter];
timeFormatter.referenceDate = [dateFormatter dateFromString:dateString];
x.labelFormatter = timeFormatter;
Now for annual mode x tick inteval should be one month. I tried the code below but didn't work
oneXUnit = 60 * 60 * 24 * 30;
x.majorIntervalLength = CPDecimalFromFloat((float) oneXUnit);
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]autorelease];
NSString *dateString = @"Jan";
[dateFormatter setDateFormat:@"MMM"];
CPTimeFormatter *timeFormatter = [[CPTimeFormatter alloc]initWithDateFormatter:dateFormatter];
timeFormatter.referenceDate = [dateFormatter dateFromString:dateString];
x.labelFormatter = timeFormatter;
I think this logic fails because the number of days for each month is different. Now the months are displayed on the x axis, but it is displayed as
Jan, , , , , , , , , , ,
, , 2 . . ?
,