這是我用隨機數據 http://jsfiddle.net/Fw4PZ/Highcharts - 更新圖表用ajax
$(function() {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
var chart;
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'area',
marginRight: 10,
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series[1];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true);
}, 1000);
}
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
Highcharts.numberFormat(this.y, 2);
}
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Random data',
data: []
},{
name: 'Random data',
type: 'spline',
data: []
}]
});
});
});
如何更新每個系列樣品圖,不僅[1]?
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true);
}, 1000);
// set up the updating of the chart each second
var series = this.series[1];
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true);
}, 1000);
}
不工作...
和2東西......如何使用AJAX來更新這些系列? (我需要有2個區域和4個樣條)
UPDATE 所以我改變了
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series;
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
series[0].addPoint([x, y], false);
series[1].addPoint([x, y], false);
series[2].addPoint([x, y], false);
series[3].addPoint([x, y], false);
series[4].addPoint([x, y], false);
series[5].addPoint([x, y], true);
}, 5000);
}
}
,但它崩潰我的瀏覽器:\ http://jsfiddle.net/2tmRB/1/(!注意與鏈接) 我做錯了嗎?
但是我無法打開這個例子,因爲所有的都被凍結了。看看例子:http://jsfiddle.net/Fw4PZ/3/,它工作正常。 –