I used CPTScatterPlotto display a graph of time series data like yours.
, . NSArray : observationDate observationValue. CPTPlotDataSource. , :
#pragma mark- CPPlotDataSource protocol methods
- (NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{
return [self.timeSeries count];
}
-(NSNumber *)numberForPlot:(CPTPlot *)plot
field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index
{
NSNumber * result = [[NSNumber alloc] init];
if (fieldEnum == CPTScatterPlotFieldX)
{
NSDate * observationDate = [[self.timeSeries objectAtIndex:index] observationDate];
NSTimeInterval secondsSince1970 = [observationDate timeIntervalSince1970];
result = [NSNumber numberWithDouble:secondsSince1970];
}
else
{
result = [[self.timeSeries objectAtIndex:index] observationValue];
}
return result;
}
, , . , , min/max - PlotSpace .
, dataSource CPTScatterPlot:
...
CPTXYGraph * myGraph = [[CPTXYGraph alloc] initWithFrame:self.bounds];
...
CPTScatterPlot * myPlot = [[CPTScatterPlot alloc] initWithFrame:graph.defaultPlotSpace.accessibilityFrame];
myPlot.dataSource = graphDataSource;
[myGraph addPlot:myPlot];
...
CPTTestApp . , , . !