我想建立一个用蜡烛棒显示库存的网络图表。首先,我从url加载历史记录json,然后每秒加载当前蜡烛棒数据并更新最后一根蜡烛棒。但是,在setInterval函数中,我无法从图表中加载系列数据。始终返回null
$.getJSON('my_first_url', function(json) {
Highcharts.stockChart('container', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Stock Price'
},
series: [{
type: 'candlestick',
name: 'AAPL Stock Price',
data: json
}],
chart: {
events: {
load: function() {
var series = this.series[0];
setInterval(function() {
$.getJSON('my_second_url', function(response) {
var data_time = jsonValue[0];
var data_open = jsonValue[1];
var data_high = jsonValue[3];
var data_low = jsonValue[4];
var data_close = jsonValue[5];
var length = series.data.length;
series.data[length - 1].update([data_time_open, data_open, data_high, data_low, data_close], true, true);
});
}, 1000);
}
}
}
});
});