0
votes

I few curiosities from the RealTimePlot.m of the CorePlotGallery sample real time plot setup:

// Plot space
CPTXYPlotSpace * plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@(kMaxDataPoints - 2)];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@1.0];
plotSpace.allowsUserInteraction = YES;

It notes a range of points - kMaxDataPoints, initially 52, which appears to be the visible range of plot points from the initial window/view size.

The delegate newData method trims the earliest point to be added, to maintain this queue but my question is how was this value (52) derived?

Is it possible to calc at run-time this visible range even when the user pinches / zooms?

Wouldn't it better to trim the point(s) afterwards - after adding, when the quantity is known of points added, from the range beginning?

1

1 Answers

1
votes

It's a "magic number" derived by saying "that's looks good" rather than any empirical method. Of course you can calculate it based on the size of the plot area. Using a constant is just a shortcut. Because of the design of the app, we know that the graph won't change size on iOS, so it's a reasonable shortcut to make there.

I don't understand the last part of the question.