miyamiya
Posts: 8
Joined: Fri Feb 03, 2023 8:24 am

Help needed with histogram bars being aligned correctly with desired ticks

For the starters, here is a link to my fiddle: https://jsfiddle.net/lauri1/6ydfavs2/6/

I would like to have a tick interval of 5, starting from -50 to 50. The bins should then be between -50 and -45, -45 and -40 and so on. Currently, however the bars are not aligned as such despite I have formatted the code the produce the desired outcome. Could someone help?

Thanks in advance!

-Miya
jedrzej.r
Posts: 725
Joined: Tue Jan 24, 2023 11:21 am

Re: Help needed with histogram bars being aligned correctly with desired ticks

Hi!

Thanks for contacting us with your question.

From the demo you've attached, it seems that the histogram series is working correctly, because on a xAxis range set from -50 to 50, the range of data is (-19, 37), so that's how the bins are placed on the xAxis. You can override bins placement by setting binWidth property, but I assume it's not exactly what you're looking for.

If you want to have bins placed exactly between each tick on xAxis range, your data should consist of integers in the same range as xAxis.

API: https://api.highcharts.com/highcharts/s ... m.binWidth

In case of any other questions, feel free to ask anytime.
Best regards!
Jędrzej Ruta
Highcharts Developer

Return to “Highcharts Usage”