Adding a very good answer to Julian D , the following avoids the potential problem of repositioning if your calculated max changes in the number of digits to the desired upper bound.
In my case, I had percentage data that is currently included in 20, but I need a range from 0 to at least 100, with the ability to jump to 100 if necessary, so the following settings are min and max in the code, then if dataMax is higher, reassigns max to its value. This means that the positioning of the graph is always calculated with sufficient space for three-digit values, and not for two-digit numbers, and then it is split into β100β compression, but allows up to β999β before the problem occurs.
var chart = new Highcharts.Chart({ chart: { renderTo: 'container', events: { load: function(event) { thisSetMax = this.yAxis[0].getExtremes().max; thisDataMax = this.yAxis[0].getExtremes().dataMax; if (thisDataMax > thisSetMax) { this.yAxis[0].setExtremes(0, thisDataMax); alert('Resizing Max from ' + thisSetMax + ' to ' + thisDataMax); } } } }, title: { text: 'My Graph' }, xAxis: { categories: ['Jan 2013', 'Feb 2013', 'Mar 2013', 'Apr 2013', 'May 2013', 'Jun 2013'] }, yAxis: { min: 0, max: 100, title: { text: '% Due Tasks Done' } }
David bell
source share