I am new to CorePlot and having a little trouble understanding "data source". I am sure that I have most likely misinterpreted some of the functions. Right now, I am trying to display the 2 json data I have already gotten and saved into _soldarray and _datearray.
example of the data received (as it is on nsLog):
_soldarray : {0, 0, 0, "62.69", "48.3", 81,}
_datearray : {("02/07/12", "02/10/12", "02/14/12", "02/11/12", "02/10/12", "02/12/12"}
and I have
CPTPlotDataSource methods
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot {
return [_soldarray count];
}
-(NSArray *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSUInteger)index {
switch (fieldEnum) {
case CPTScatterPlotFieldX:
for (int i =0 ; 50;i++){
return [_datearray objectAtIndex:i];
}
break;
case CPTScatterPlotFieldY:
for (int j =0 ; 50;j++){
return [_soldarray objectAtIndex:j];
}
break;
}
return 0;
}
and as for configuration:
CPTGraph *graph = self.hostView.hostedGraph;
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) graph.defaultPlotSpace;
// 2 - Create the three plots
CPTScatterPlot *aaplPlot = [[CPTScatterPlot alloc] init];
aaplPlot.dataSource = self;
aaplPlot.identifier = _soldarray;
CPTColor *aaplColor = [CPTColor redColor];
[graph addPlot:aaplPlot toPlotSpace:plotSpace];
I tried changing datasource to the array but that does not work as well. Can someone point me to the right directions. I am having trouble understanding how plot.datasource and how -(NSArray *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSUInteger) index works. Thanks in advance!