lucafo
Posts: 1
Joined: Wed May 18, 2022 7:04 pm

xAxis.overscroll being ignored when setting new max with setExtremes

Hi!
I'm using highcharts stock with a candlestick series and I implemented a custom zoom and panning effects.
Both of these I implemented with mouse events listeners and axis.setExtremes calls.
Also, I'm using the xAxis.overscroll property to set a right margin to my plotted series that have a ordinal x axis.

The problem I have is that, when I change the max range value with setExtremes, the overscroll is lost and I cannot pan the chart over the last candle anymore.

Before panning (with overscroll):
Image

After panning just a little bit to either side (overscroll lost)
Image

How can I change the max range value with setExtremes without losing the overscroll when I'm back to the original max range?
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: xAxis.overscroll being ignored when setting new max with setExtremes

Hello lucafo,
Welcome to our forum and thanks for contacting us with your question!

The overscroll is being lost, because setExtremes method is overwriting all extremes in chart, including overscroll. If you want to keep the padding from right side of axis you should include the overscroll value in setExtremes method - just like in the demo below.

Demo: https://jsfiddle.net/BlackLabel/4agetf7j/

Let me know if that was what you were looking for!
Regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Stock”