Here is my sample chart with random data http://jsfiddle.net/Fw4PZ/
$(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: []
}]
});
});
});
How to update each series, not only [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);
}
Doesn't work...
And 2nd thing... how to update those series using ajax? (I need to have 2 areas and 4 splines)
UPDATE So i change this
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);
}
}
but it crashes my browser :\ http://jsfiddle.net/2tmRB/1/ (watch out with that link!) What I'm doing wrong?