Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setExtremes in xAxis event handler?

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.

like image 622
Nikos Avatar asked May 02 '13 21:05

Nikos


1 Answers

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);
             }
         }
     }
 }
like image 168
Thestrup Avatar answered Sep 22 '22 22:09

Thestrup