Search code examples
iosswiftaxiscore-plot

Axis constraint for Coreplot axis set in Swift


Currently I'm converting objective-C based plotting app to the swift and most of the parts are knife in the butter, but I'm struck when it comes to the axis positioning.

In objective-C I used the below two lines to fix the axis on the plot,

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
CPTXYAxis *x = axisSet.xAxis;

x.orthogonalPosition = @0.0
x.axisConstraints = [CPTConstraints constraintsWithLowerOffset: 0.0];

The problem here is, the swift implementation is void of these two properties

  • orthogonalPosition

  • axisConstraints

So, if anybody knows the correct way of doing this or any workaround for fixing the axis in the plot kindly provide a helping hand. Thanks in advance.


Solution

  • Try this:

    x.orthogonalPosition = 0.0
    x.axisConstraints = CPTConstraints(lowerOffset: 0.0)