/ Published in: iPhone
Begin by making the class a CPPlotSpaceDelegate.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// in the viewDidLoad Method: // CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace; // plotSpace.delegate = self; /* * "Dock" the Y-axis and only allow horizontal scrolling toward the right. */ - (CPPlotRange *)plotSpace:(CPPlotSpace *)space willChangePlotRangeTo:(CPPlotRange *)newRange forCoordinate:(CPCoordinate)coordinate { NSLog(@"WillChangePlotRangeTo"); // only allows scrolling to the right // remove this to have scrolling in both directions if (newRange.locationDouble < 0.0F) { newRange.location = CPDecimalFromFloat(0.0); } // Adjust axis to keep them in view at the left and bottom; // adjust scale-labels to match the scroll. CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet; if (coordinate == CPCoordinateX) { axisSet.yAxis.orthogonalCoordinateDecimal = newRange.location; axisSet.xAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble + (newRange.lengthDouble / 2.0F)); } else { axisSet.xAxis.orthogonalCoordinateDecimal = newRange.location; axisSet.yAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble + (newRange.lengthDouble / 2.0F)); } return newRange; }