Search code examples
iosswiftcore-plotaxes

iOS Swift - Custom Axis Labels -- Core Plot Bar Graph


TL;DR Is there a way to set a custom axis label's tick location in Swift (using core-plot lib)?

i want to set custom labels for an axis in a CPTXYGraph. I have created the label and set it to the xAxis like so:

xAxis.axisLabels = NSSet(array: customLabels)

that part is fine. What is NOT fine, is that I can't set the location or index of the label to match it up with the 'tick' on the xAxis.

in Objective C, you can set a property

label.tickLocation

but I can't find the corresponding property or any pertinent method in Swift. I can't find any class references in Swift, either. Is there a way to set the label's tick location in Swift?


Solution

  • there is no property called tickLocation because NSDecimal was done away with in Swift. I had to extend CPTAxisLabel and create my own method setTickLocation. Fun stuff