如何在xAxis事件处理程序中设置textrees



我正试图在下面的xAxis事件处理程序中设置textrees,我正在获得未捕获的TypeError。如何在xAxis事件处理程序中设置textrees ?

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 
            }
        }
    }
},

我将感谢任何可用的帮助或解决方法。谢谢。

我知道这有点晚了,只是想把我的答案添加给未来的访问者。

Highchart不允许从setextrees事件处理程序内部调用setextrees,以避免无限循环。这就是你得到错误的原因。

但是,您可以插入超时以绕过此保护:
 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);
             }
         }
     }
 }

看起来highcharts实际上是在回调期间将xAxis对象的所有属性设置为null。你不需要这么做你可以直接注释出错误的那行然后就没事了

最新更新