I am using core-plot lib to draw bar charts in my app like this
My problem is that i want the enabling of grapgh movement only in horizontal direction so that I can see the records for a long period of time, But the problem is that i just wnt to keep the y axis fixed to its place,
How can i do this?
Waiting for help....
Limit scrolling by setting a delegate (i.e., CPPlotSpaceDelegate) on the plot space and implement the willChangePlotRangeTo method. You can do other cool things at the same time. Here's how I limit the display to quadrant one:
- (CPPlotRange *)plotSpace:(CPPlotSpace *)space
willChangePlotRangeTo:(CPPlotRange *)newRange
forCoordinate:(CPCoordinate)coordinate {
// Display only Quadrant I: never let the location go negative.
//
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 *)self.graph.axisSet;
if (coordinate == CPCoordinateX) {
axisSet.yAxis.orthogonalCoordinateDecimal = newRange.location;
axisSet.xAxis.titleLocation = CPDecimalFromFloat(newRange. newRange.locationDouble +
(newRange.lengthDouble / 2.0F));
} else {
axisSet.xAxis.orthogonalCoordinateDecimal = newRange.location;
axisSet.yAxis.titleLocation = CPDecimalFromFloat(newRange.locationDouble +
(newRange.lengthDouble / 2.0F));
}
return newRange;
}
See: CPPlotSpace.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With