The problem is that the setExtremes(min, max) method returns undefined , so you cannot bind parameters. The solution is to wrap this method and pass the context, for example:
(function(H) { H.wrap(H.Axis.prototype, 'setExtremes', function (proceed) { proceed.apply(this, Array.prototype.slice.call(arguments, 1); return this; // <-- context for chaining }); })(Highcharts);
Now we can use:
return window.Highcharts.charts[0].xAxis[0].setExtremes(min, max).series[0].options.data;
Note: the fragment can be placed in a separate file and used like any other Highcharts plugin (just download it after the Highcharts library).
Attention!
An Axis object only has links to series attached to this axis. If you want to access any series on the chart, use:
return window.Highcharts.charts[0].xAxis[0].setExtremes(min, max).chart.series[0].options.data;
Paweł fus
source share