I have a Core-Plot scatter plot that seems to be working great. The x axis shows date/time, the y axis a value from 0-500. I set up the x axis as follows:
plotSpace.xRange = [CPPlotRange plotRangeWithLocation:
CPDecimalFromFloat(maxTime - 2*60*60*24)
length:CPDecimalFromFloat(2.5*60*60*24)];
plotSpace.globalXRange = [CPPlotRange plotRangeWithLocation:
CPDecimalFromFloat(minTime - 1.5*60*60*24)
length:CPDecimalFromFloat(maxTime - minTime + 2*60*60*24)];
x.majorIntervalLength = CPDecimalFromFloat(12*60*60);
x.minorTicksPerInterval = 0;
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"M/d H:mm a"];
CPTimeFormatter *timeFormatter = [[[CPTimeFormatter alloc]
initWithDateFormatter:dateFormatter] autorelease];
timeFormatter.referenceDate = [NSDate
dateWithTimeIntervalSinceReferenceDate:0];
x.labelFormatter = timeFormatter;
My x-axis points are plotted as follows:
-(NSNumber *)numberForPlot:(CPPlot *)plot
field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index
{
if(fieldEnum == CPScatterPlotFieldX) {
return [NSNumber numberWithDouble:[[(Entry *)
[datapoints objectAtIndex:index] datetime]
timeIntervalSinceReferenceDate]];
}
As far as I can tell, everything is being plotted accurately. BUT, for some reason, the ticks occur at 5 AM and 5 PM, rather than noon and midnight as I would prefer.
I've tried everything -- changing the xRange and globalXRange location and length, altering my dataset, etc. But every time the labels reappear at 5 AM and 5 PM. Can you help? Thanks!