0

I have tried to using [graph reloadData] to refresh my data for a scatterplot,but i didn't get the correct y-axist. Here is my y-axist code:

CPTXYAxis *y = axisSet.yAxis;
y.title = @"";
y.titleTextStyle = axisTitleStyle;
y.titleOffset = 20.0f;
y.axisLineStyle = axisLineStyle;
//y.majorGridLineStyle = gridLineStyle;
y.labelingPolicy = CPTAxisLabelingPolicyAutomatic;
y.labelTextStyle = axisTextStyle;
y.labelOffset = -40.0f;
y.majorTickLineStyle = tickLineStyle;
tickLineStyle.lineWidth = 0.1f;
y.minorTickLineStyle = tickLineStyle;
y.majorTickLength = 2.0f;
y.minorTickLength = 1.0f;
y.tickDirection = CPTSignPositive;
y.plotSpace = graph.defaultPlotSpace;

Is there anyway to change the y scale dynamically when i have called the reloadData method?

Jay Shore
  • 3
  • 2

1 Answers1

0

You need to update the plotSpace dimensions, something like this:

(code typed in my browser, not tested):

[y.plotSpace setYRange:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(minYValue) length:CPTDecimalFromFloat(maxYValue - minYValue)];
koen
  • 5,383
  • 7
  • 50
  • 89
  • I need to know the maxYValue and minYValue in this way,but I don't think I have known it. – Jay Shore Dec 10 '14 at 02:18
  • What is your dataSource? If it is an array with x-y values, it shouldn't be too difficult to get the min and max values for both coordinates, see eg here: http://stackoverflow.com/questions/15931112/finding-the-smallest-and-biggest-value-in-nsarray-of-nsnumbers – koen Dec 10 '14 at 13:13