CorePlot - Set y-Axis range to include all data points

Posted by zdestiny on Stack Overflow See other posts from Stack Overflow or by zdestiny
Published on 2012-03-21T16:13:26Z Indexed on 2012/03/21 23:29 UTC
Read the original article Hit count: 245

Filed under:
|
|
|

I have implemented a CorePlot graph in my iOS application, however I am unable to dynamically size the y-Axis based on the data points in the set. Some datasets range from 10-50, while others would range from 400-500. In both cases, I would like to have y-origin (0) visible.

I have tried using the scaletofitplots method:

[graph.defaultPlotSpace scaleToFitPlots:[graph allPlots]];

but this has no effect on the graphs, they still show the default Y-Axis range of 0 to 1.

The only way that I can change the y-Axis is to do it manually via this:

graph.defaultPlotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f)) length:CPTDecimalFromFloat(500.0f)];

however this doesn't work well for graphs with smaller ranges (10-50), as you can imagine.

Is there any method to retrieve the highest y-value from my dataset so that I can manually set the maximum y-Axis to that value? Or is there a better alternative?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c