How to setExtremes in xAxis event handler?

highcharts

Solution

I know this is it bit late, just wanted to add my answer to future visitors.

Highchart doesn't allow to call setExtremes from inside the setExtremes eventhandler in order to avoid an endless loop. That's why you get the error.

You can, however, insert a timeout in order to work around this protection:

 xAxis: {
     events: {
         setExtremes: function (e) {
             if (e.trigger === "navigator") {
                 var c = this;
                 setTimeout(function() {
                     forceRebuildSeries(); //Get all data points

                     // Set Extremes (redisplay with new data points)
                     c.chart.xAxis[0].setExtremes(e.min, e.max);  

                 }, 1);
             }
         }
     }
 }

Problem

I am trying to setExtremes in the xAxis event handler below and I am getting the Uncaught TypeError. How can I setExtremes in the xAxis event handler? ``` xAxis: { events: { setExtremes: function (e) { if (e.trigger === "navigator") { forceRebuildSeries(); //Get all data points // Set Extremes (redisplay with new data points) this.chart.xAxis[0].setExtremes(e.min, e.max); //Uncaught TypeError: Property 'setExtremes' of object #<Object> is not a function } } } }, ``` I would appreciate any help or workaround available. Thanks.

Original source