Reputation: 65
I am creating a small iPhone application using CorePlot. The graph consists of 10 bars. Unfortunately, the y-values might differ between 0 and 1 million, therefore I create my plotspace with a rather huge yRange
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(yAxisStart)
length:CPTDecimalFromDouble(yAxisLength)];
What I am experiencing is that my application is really slow when loading the graph, and I can pinpoint this issue to the rather large value of yAxisLength. I already removed the creation of tickmarks on the y axis, but still the performance is very bad. Can anyone give me a hint how to improve performance?
Upvotes: 1
Views: 466
Reputation: 1514
y.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
y.majorGridLineStyle = nil;
y.minorGridLineStyle = nil;
y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
y.majorIntervalLength = CPTDecimalFromDouble(maxRange/2.0);
worked for me.
Upvotes: 0
Reputation: 27381
Make sure you update the labeling parameters, even if you don't need any labels or ticks. The default labeling policy creates tick marks and labels one unit apart. That's why a large axis range slows your app down so much. It also creates a separate Core Animation layer for each label. Creating 1 million labels will take a long time and use a lot of memory.
If you don't need any ticks or labels, set the labeling policy to CPTAxisLabelingPolicyNone
. Otherwise, make the necessary adjustments to the various labeling properties (which ones to use depends on which policy you choose) so that there are reasonable number of ticks within the axis range.
Upvotes: 3
Reputation: 4436
I haven't used CorePlot, but maybe you can scale your data before trying to plot it.
If the y-scale ranges up to a million, then divide y-max and all your y-values by 100,000. Then just add something like "(x100,000)" to the y-axis label.
Upvotes: 0