I have a timer that is updating my coreplot data to give the illusion of real time stats. When the timer fires it adds a value to an array and refreshes the scatter plot. This works great, however once I graph about 10 data points I want to start removing the first points and only displaying the last 10 datapoints. But when I try to remove data a point it displays the old and the new datapoints on top of eachother. I can't figure out why this would be. I have tried to nil out the array and reset it and all to no avail. Any ideas on why this would be happening. Here is some code:
//START GRAPHING
self.count = 0;
if (numberOfPackets == 1){ //on the first packet
[self.repeatingTimer invalidate];
self.repeatingTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateArray:) userInfo:nil repeats:YES];
self.arrayII = [[NSMutableArray alloc] init];
[self initPlot];
}
-(void) updateArray:(NSTimer *)timer{
self.count++;
// self.arrayII sources scatter plot data.
if (self.count < [dataPacketArray count]){
if (self.count > 5){
[self.arrayII removeObjectAtIndex:0]; //if I don't include this it works flawlessly.
}
[self.arrayII addObject:[dataPacketArray objectAtIndex:self.count]];
}
[self.view reloadInputViews];
[self configurePlots];
}
-(void) initPlot {
[self configureHost];
[self configureGraph];
[self configurePlots];
[self configureAxes];
}
I got all the init plot stuff from this tutorial. Any help is greatly appreciated.