2017-05-04 45 views

回答

1

這裏的一個問題是xAxis對象的maxZoom屬性。使用它可以指定最小範圍xAxis,該範圍已存在:maxZoom設置爲20000。要將點對齊到左側,您可以從配置中刪除此屬性。這是我編輯的這個小提琴的版本:https://jsfiddle.net/arcquim/y9eaw1rf/13/

順便說一下,maxZoom已棄用,並換成新的minRange屬性。

1

如果你想保持maxZoom(minRange實際)屬性,你需要在第一個點的添加時設置axis min,當你開始移動點時 - 你應該重置min,這樣圖表就能夠改變它的極值。

 load: function() { 

    // set up the updating of the chart each second 
    var chart = this; 
    var series = this.series[0]; 
    var minSet = false; 
    var extremesReset = false; 

    setInterval(function() { 
     var x = (new Date()).getTime(), // current time 
     y = Math.round(Math.random() * 100); 

     if (!minSet) { 
     chart.xAxis[0].update({ 
      min: x 
     }, false); 
     minSet = true; 
     } 

     if (series.data.length > 20 && !extremesReset) { 
     chart.xAxis[0].update({ 
      min: null, 
     }, false) 
     extremesReset = true; 
     } 

     series.addPoint([x, y], true, series.data.length > 20, series.data.length); 

    }, 1000); 
    } 

例如:http://jsfiddle.net/xbrwqk46/