0
我有一個highcharts排行榜運行具有AJAX,Highcharts,負載然後刷新
它獲得的數據並刷新每15秒,這是完全沒有
除外,我需要該圖表以遠離然後striaght加載每15秒刷新一次,
目前它在頁面加載顯示前等待15秒。下面
function getLiveData() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: '/get-converted-data',
success: function(point) {
var x = (new Date()).getTime();
console.log(point);
var series = liveChart.series[0];
var series1 = liveChart.series[1];
var series2 = liveChart.series[2];
var series3 = liveChart.series[3];
shift = series.data.length > 20;
shift1 = series1.data.length > 20;
shift2 = series2.data.length > 20;
shift3 = series3.data.length > 20;
// add the points
liveChart.series[0].addPoint([x, point[0]], true, shift);
liveChart.series[1].addPoint([x, point[1]], true, shift1);
liveChart.series[2].addPoint([x, point[2]], true, shift2);
liveChart.series[3].addPoint([x, point[3]], true, shift3);
// call it again after 15 seconds,
//this is loading the actual chart every 15 seconds,
//i need the chart to load instantly then refresh every 15 seconds, any ideas?
setTimeout(getLiveData, 15000);
},
cache: false
});
}
你只需要調用'getLiveData()'只要頁面加載 –
哇,謝謝,無法相信我錯過了 –