I’m facing a problem with plotting data using the CorePlot framework. I have integrated it and below there’s a sample of my code from the project I’m working on: live scatter
chart.
If my data sources have the same values then graph is not plotting.
This is the code for plotting points:
#pragma mark - CPTPlotDataSource methods
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot {
return [appDelegate.arrayLiveValues count];
}
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum
recordIndex:(NSUInteger)index
{
NSInteger valueCount = [appDelegate.arrayLiveValues count];
switch (fieldEnum) {
case CPTScatterPlotFieldX:
if (index < valueCount) {
return [NSNumber numberWithUnsignedInteger:index];
}
break;
case CPTScatterPlotFieldY:
return [appDelegate.arrayLiveValues objectAtIndex:index];
break;
}
return [NSDecimalNumber zero];
}
If appDelegate.arrayLiveValues array contains duplicate values then it’s not plotting. If it have different values it’s plotting the graph, based on values in datasource, i.e. appDelegate.arrayLiveValues the graph zoom level is setting.
I want to know the what’s the inner functionality
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index method;
Yes Exactly we have to set min max bounds according to our values.