Highcharts 保持滚动至右高图表

Highcharts 保持滚动至右高图表,highcharts,highstock,Highcharts,Highstock,有没有办法让卷轴保持在最右边? 我正在尝试highchart上的实时更新,似乎有时我会遇到scroll被甩在后面 $(function() { Highcharts.setOptions({ global: { useUTC: false } }); // Create the chart $('#container').highcharts('StockChart', { chart: { events: { load: function

有没有办法让卷轴保持在最右边? 我正在尝试highchart上的实时更新,似乎有时我会遇到scroll被甩在后面

$(function() {

   Highcharts.setOptions({
       global: {
        useUTC: false
}
 });

 // Create the chart
$('#container').highcharts('StockChart', {
chart: {
  events: {
    load: function() {

      // set up the updating of the chart each second
      var series = this.series[0],
        hasPlotLine = false,
        $button = $('#button'),
        chart = $('#container').highcharts(),
        yAxis = chart.yAxis[0],
        plotLine,
        d,
        newY;

      yAxis.addPlotLine({
        value: 66,
        color: 'red',
        width: 2,
        id: 'plot-line-1',
                    label: {
                text: 66,
                align: 'right',
                y: newY,
                x: 0
            }
      });

      setInterval(function() {

        var x = (new Date()).getTime(), // current time
          y = Math.round(Math.random() * 100);
        series.addPoint([x, y], true, true);

        plotLine = yAxis.plotLinesAndBands[0].svgElem;

        d = plotLine.d.split(' ');

        newY = yAxis.toPixels(y) - d[2];

        plotlabel = yAxis.plotLinesAndBands[0].label;

                    plotlabel.animate({
            translateY:newY,
                        text:y
        },400),   


        plotLine.animate({
          translateY: newY
        }, 400);


      }, 1000);
    }
  }
},

rangeSelector: {
  buttons: [{
    count: 1,
    type: 'minute',
    text: '1M'
  }, {
    count: 5,
    type: 'minute',
    text: '5M'
  }, {
    type: 'all',
    text: 'All'
  }],
  inputEnabled: false,
  selected: 0
},

title: {
  text: 'Live random data'
},

exporting: {
  enabled: false
},

series: [{
  name: 'Random data',
  data: (function() {
    // generate an array of random data
    var data = [],
      time = (new Date()).getTime(),
      i;

    for (i = -999; i <= 0; i += 1) {
      data.push([
        time + i * 1000,
        Math.round(Math.random() * 100)
      ]);
    }
    return data;
  }())
}]

});

});
$(函数(){
Highcharts.setOptions({
全球:{
useUTC:false
}
});
//创建图表
$(“#容器”).highcharts('StockChart'{
图表:{
活动:{
加载:函数(){
//设置图表的每秒更新
var series=此.series[0],
hasPlotLine=false,
$按钮=$(“#按钮”),
图表=$(“#容器”).highcharts(),
yAxis=chart.yAxis[0],
绘图线,
D
纽伊;
yAxis.addPlotLine({
价值:66,
颜色:“红色”,
宽度:2,
id:“plot-line-1”,
标签:{
案文:66,
对齐:“右”,
y:新的,
x:0
}
});
setInterval(函数(){
var x=(新日期()).getTime(),//当前时间
y=数学圆(数学随机()*100);
系列。添加点([x,y],真,真);
plotLine=yAxis.plotlinesandband[0].svgElem;
d=绘图线。d.分割(“”);
newY=yAxis.toPixels(y)-d[2];
plotlabel=yAxis.plotlinesandband[0]。标签;
plotlabel.animate({
特兰西:新的,
文本:y
},400),   
plotLine.animate({
特兰西:新的
}, 400);
}, 1000);
}
}
},
范围选择器:{
按钮:[{
计数:1,
键入:“分钟”,
文字:“1M”
}, {
计数:5,
键入:“分钟”,
文字:“5M”
}, {
键入:“全部”,
文字:“全部”
}],
输入:错误,
已选:0
},
标题:{
文本:“实时随机数据”
},
出口:{
已启用:false
},
系列:[{
名称:'随机数据',
数据:(函数(){
//生成一个随机数据数组
var数据=[],
时间=(新日期()).getTime(),
我
对于(i=-999;isetextrems()将起作用-请参阅API

唯一需要调整的是最小值-您可以从最后一个点开始计算或设置某个固定值

xAxis.setExtremes(x - 1000 * 60, x)
例如: