rdp1414
Posts: 41
Joined: Wed Oct 27, 2021 2:06 pm

Needless vacant space at axes boundaries

Suppose a chart has plotted y-values whose max value is 99. There is needless vacant space from 100 to 125 - See [fiddle](https://jsfiddle.net/rh98zw2a/). This space is useless because there is no value to show in this range.

I tried setting [yAxis.max](https://api.highcharts.com/highcharts/yAxis.max) to 105 to remove the extra vacant space; but it didn't work - See [fiddle](https://jsfiddle.net/ro5mLgzu/). You can see that still that needless vacant space from 100-125 is present.

Can you please suggest some solution to have tighter axis limits? Also, do tell why setting `yAxis.max` didn't take effect?
jakub.s
Posts: 1228
Joined: Fri Dec 16, 2022 11:45 am

Re: Needless vacant space at axes boundaries

Hi,

Thanks for the question.

yAxis.max as well as yAxis.min are influenced by many other properties. You can read about this in the API: https://api.highcharts.com/highcharts/yAxis.max

By setting yAxis.endOnTick to false, the "needless" space you want to get rid of will disappear. Take a look at this demo: https://jsfiddle.net/BlackLabel/vLzdqymn/

Let me know if that solves your problem.

Best regards,
Jakub
Jakub
Highcharts Developer
rdp1414
Posts: 41
Joined: Wed Oct 27, 2021 2:06 pm

Re: Needless vacant space at axes boundaries

Hello Jakub,

Thanks for the suggestion - it worked. So, our aim is to have "tight extremes such that there is almost no extra space beyond the data points". To achieve this our team has configured few options (along with reasonings) - See [fiddle](https://jsfiddle.net/ykpuxsc0/). I just wanted to request for your opinion about this.

Thank You
rdp1414
Posts: 41
Joined: Wed Oct 27, 2021 2:06 pm

Re: Needless vacant space at axes boundaries

The most prominent issue with the above "tight extremes" is misaligned gridLines when multiple yAxes are present - See [fiddle](https://jsfiddle.net/2rovt3sL/).
rdp1414
Posts: 41
Joined: Wed Oct 27, 2021 2:06 pm

Re: Needless vacant space at axes boundaries

Also the [chart.alignThreshold](https://api.highcharts.com/highcharts/c ... Thresholds) option is not working in the above fiddle.
jakub.s
Posts: 1228
Joined: Fri Dec 16, 2022 11:45 am

Re: Needless vacant space at axes boundaries

Hi,

1. Everything works & the code is perfectly fine!

2. When you set chart.yAxis.startOnTick and chart.yAxis.endOnTick to false on every yAxis that you have in your chart, the tick lines cannot be aligned.

You can read about this in the last link to the docs you've sent:
If startOnTick or endOnTick in the axis options are set to false, or if the axis is logarithmic, the threshold will not be aligned.

If you describe to me what you're trying to achieve exactly (or maybe send me an image of a desired chart), I'll gladly help you create that!

Best regards,
Jakub
Jakub
Highcharts Developer

Return to “Highcharts Stock”