i use coreplot library 0.9 in my iPad application.
Here, i use a scatter plot with a fixed y-range (no scrolling in y direction), i.e. plot space range = global range (see source code below).
When new data is available (MOC observation) i add data to plot’s data array (scatter plot), determine the new y-range required (min/max value in data array) and reload the whole plot.
If the value of the new data is greater than the other values, the plot displays it out of bounds although the plot space has been adapted to the new range.
But:
If the MOC change is not due to inserting new data (bigger than the old ones) but instead due to deleting data (which had the biggest value in plot data array), the result is perfect: The plot uses the full range –> range adaption (decreasing plot space range) takes place. Why does this not work in the other direction (increasing plot space range), too?
I am really stuck here and would be glad if someone could help me with that. Thanks.
-(void) mocChangeNotification:(NSNotification *)notification
{
...
[self performSelectorOnMainThread:@selector(refresh) withObject:nil waitUntilDone:NO];
}
- (void) setYAxisValueRange
{
...
myOwnPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(minDisplay)
length:CPTDecimalFromFloat(maxDisplay)];
// disable "scrolling" in y-direction
myOwnPlotSpace.globalYRange = myOwnPlotSpace.yRange;
}
- (void) refresh
{
[dataForPlot removeAllObjects];
[self preparePlotData]; // put data into plot's data array
[self setYAxisValueRange]; // looks for min / max values in data
[myPlot reloadData];
}
These screenshots show the situation (since i am new to Stack Overflow, i am not yet allowed to post pictures): http://gallery.me.com/timoseeberger#100038&view=grid&bgcolor=black&sel=5
1) Initial display of plot (everything is fine):
file: screenshot_graph_initial
2) I add new value (200) to plot –> display out of bounds (upper end)
file: screenshot_graph_adding200
3) I remove values 200 and 150 from plot –> plot display adapts perfectly
file: screenshot_graph_deleting150
4) I add new value (40) to plot –> display out of bounds (lower end)
file: screenshot_graph_adding40
Plot ranges have a starting location and length. Your location is ok; use
maxDisplay - minDisplayfor the length.Make sure that your plot uses the plot space that you’re updating: