klhebs
Posts: 16
Joined: Thu Apr 01, 2021 8:24 am

highstock xaxis ordinal and broken xaxis problem

hi, i would like to ask that if i set breaks on xaxis initially then i change the data and set the x axis with ordinal:true, the breaks between trading days will still be affected by the broken axis instead of the ordinal axis? which is the case now. is there any way to toggle xaxis to ordinal and when it is true the chart will auto skip all non-trading time? Much thanks
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: highstock xaxis ordinal and broken xaxis problem

Hello klhebs,

Not quite sure if that is an answer for your question, but even with ordinal: true breaks will be visible. Ordinal option makes sure that points are spaced equally regardless of the time, distance and different similar factors. Even though breaks doesn't show any data it is still meaningful and enabled ordinal option shows such periods, the only thing that is changed is regardless of the period length the space between points is exactly the same.
Demo: https://jsfiddle.net/BlackLabel/3tjqbuyw/
API reference: https://api.highcharts.com/highstock/xAxis.ordinal

Regards!
Mateusz Bernacik
Highcharts Developer
klhebs
Posts: 16
Joined: Thu Apr 01, 2021 8:24 am

Re: highstock xaxis ordinal and broken xaxis problem

mateusz.b wrote: Fri Oct 29, 2021 8:21 am Hello klhebs,

Not quite sure if that is an answer for your question, but even with ordinal: true breaks will be visible. Ordinal option makes sure that points are spaced equally regardless of the time, distance and different similar factors. Even though breaks doesn't show any data it is still meaningful and enabled ordinal option shows such periods, the only thing that is changed is regardless of the period length the space between points is exactly the same.
Demo: https://jsfiddle.net/BlackLabel/3tjqbuyw/
API reference: https://api.highcharts.com/highstock/xAxis.ordinal

Regards!
hi i am aware of the breaks, i am expecting the chart will be like this which is ok with the chart x axis initially set ordinal to true
Capture2.PNG
Capture2.PNG (27.66 KiB) Viewed 571 times
however i wish to set the ordinal setting to false and a break like this

Code: Select all

chart.xAxis[0].update({
              ordinal: false,
              breaks: [
                {
                  from: breakStartTimeStemp,
                  to: breakEndTimeStemp
                  // breakSize:
                }
              ]
            })

in order to show the the intraday info like this
image_2021_10_26T04_10_56_038Z.png
image_2021_10_26T04_10_56_038Z.png (91.7 KiB) Viewed 571 times
when i switch back to e.g. 5 min i update the chart with

Code: Select all

chart.xAxis[0].update({
              ordinal: true
               breaks: []
            })
it will turn out like this
image_2021_10_26T09_43_20_276Z.png
image_2021_10_26T09_43_20_276Z.png (222.71 KiB) Viewed 571 times
which the breaks are too large compare to the first picture.
how can i toggle the ordinal axis to achieve both scale that i need?
Much Thanks
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: highstock xaxis ordinal and broken xaxis problem

Hello klhebs,

I think I know where's the issue now, thanks for that elaborated explanation. It seems to me that when you change extremes to much shorter period (like in your example 5 min), initial breaks don't make sense anymore. You are updating chart to get rid of these breaks and toggle ordinal option. It should work, but here comes data grouping which is another factor to be taken into consideration in this case. Could you try to create a simplified working demo showing your issue? I would be really helpful in finding right solution.

Also, please try to update your axis like this:

Code: Select all

chart.xAxis[0].update({
           ordinal: true,
           breaks: undefined
   })
Regards!
Mateusz Bernacik
Highcharts Developer
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: highstock xaxis ordinal and broken xaxis problem

Quick update, in this case x axis has to be updated twice.
Demo: https://jsfiddle.net/BlackLabel/ebLj8xka/
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”