I'm trying to do a XYGraph for an iOS application using the CorePlot component but I can't manage to make an axis Floating. What I want is keeping the axis line always at the same position when the user touches and drags the screen.
I've got this code.
var axisSet = (CPTXYAxisSet) graph.AxisSet; // Label x with a fixed interval policy var x = axisSet.XAxis; x.LabelingPolicy = CPTAxisLabelingPolicy.Automatic; x.MinorTicksPerInterval = 4; x.PreferredNumberOfMajorTicks = 8; x.MajorGridLineStyle = major; x.MinorGridLineStyle = minor; x.Title = "X Axis"; x.TitleOffset = 25f; // Label y with an automatic label policy. var y = axisSet.YAxis; y.LabelingPolicy = CPTAxisLabelingPolicy.Automatic; y.MinorTicksPerInterval = 4; y.PreferredNumberOfMajorTicks = 8; y.MajorGridLineStyle = major; y.MinorGridLineStyle = minor; y.LabelOffset = -6f; y.Title = "Weight"; y.TitleOffset = -30f; //Make the Y axis start on number 40 x.OrthogonalCoordinateDecimal = NSDecimalNumber.FromFloat(40.0f).NSDecimalValue; plotspace.GetPlotRange (CPTCoordinate.X).Location = NSDecimalNumber.FromFloat(40.0f).NSDecimalValue; //Format the Y axis sufix " Kg" NSNumberFormatter newFormatter = new NSNumberFormatter(); newFormatter.MinimumIntegerDigits = 1; newFormatter.PositiveSuffix = " Kg"; y.LabelFormatter = newFormatter;
And the graph is shown properly like this.
but when the user scrolls to the up-right the axis are not visible
Now I want to make the axis always visible. I've found some Objective-C examples that use the instruction:
y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];
But I can't find the "axisConstraints" property in a CPTXYAxis object.
I've also tried with the instruction
x.IsFloatingAxis = true; but it makes the app to crash.
If anyone could help me to show floating axis I would be very pleased. Thank you in advance.