highcharts / highcharts-ios

iOS wrapper for Highcharts.
Other
127 stars 39 forks source link

Access paddedTicks #384

Closed alexiss03 closed 2 years ago

alexiss03 commented 2 years ago

Hi, is there a way or an alternative to access paddedTicks?

alexiss03 commented 2 years ago

@ihnatmoisieiev Can I follow up on this?

ihnatmoisieiev commented 2 years ago

Hello @alexiss03, why do you need to have acess to paddedTicks array? What do you want do achieve? Could you give some examples? Thank you.

alexiss03 commented 2 years ago

I need the paddedTicks to color a HIAreaspline chart to compute for a given threshold. The values of array paddedTicks will be used to what stops I need to create for the chart gradient. If paddedTicks is [68, 70, 72, 74, 76] and the threshold is {"min": 69.8, "max": 78.8, "aMin": 50,"aMax": 104}, I'm comparing 68 if it belongs between aMin && min[yellow], min && max[green], max && aMax[yellow]. Then I get the stops so if paddedTicks has a length of 5 that will be 1/5 so each paddedTick will have a stop of 0.2 so 68 since it falls between aMin and min so that color should be yellow and since it is the first tick so stop is 0 70 falls between min and max so the color is green and for the stop (for me I set the green to start on 69.8), so calculate between 68 (0.2) and 70(0.4). The stop is probably around 0.3

[0, yellow], [0.3, green], ...

ihnatmoisieiev commented 2 years ago

@alexiss03 you can get paddedTicks via closure:

chart.events.load = HIFunction(closure: { context in
  guard let context = context,
        let paddedTicks = context.getProperty("this.xAxis[0].paddedTicks") as? [Int] else { return }
  print(paddedTicks)
}, properties: ["this.xAxis[0].paddedTicks"])

Please try and let us know if it works for you. Thanks.

alexiss03 commented 2 years ago

Yes, this worked. Thank you.