Highcharts xAxis padding is lost when navigator when zooming in and out and can't get the padding back when zoom out

StackOverflow https://stackoverflow.com/questions/15762865

  •  31-03-2022
  •  | 
  •  

Question

I am using highcharts where I need extra padding on my chart. When I use navigator and zoom in I the padding is lost - which is fine as I am zooming in. However when I zoom out using Navigator I don't get my padding back. Alternatively if I use the zoom button on chart I get the padding back (I would expect the same behaviour from navigator as well when I try to zoom out).

I've copied a sample chart form Highcharts Demo on jsFiddle http://jsfiddle.net/gajjargaurav/RULh9/5/ with Navigator and http://jsfiddle.net/gajjargaurav/RULh9/4/ with Zoom button

The padding I have set is as below for my sample,

xAxis: {
            maxPadding: 0.22, //Prevent chart going off the screen on the right
            minPadding: 0.22,
            tickPosition: 'outside'
        }

The question is, how I can get the navigator to behave like the zoom button does when I try to zoom out using navigator?

Était-ce utile?

La solution

Unfortunately min/maxPadding works only for initial state. If you want to improve your range in that way, I advice to use afterSetExtremes event handler, and there setup new extremes( just increase that one you get).

Note: When setting new extremes in afterSetExtremes, will call another afterSetExtremes. Make sure. Make sure that you will not create infinite loop (add some flag checking if extremes are already improved, or not).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top