Reputation: 2094
series.addPoint (Object options, [Boolean redraw], [Boolean shift], [Mixed animation])
chart: {
events: {
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.round(Math.random() * 100);
series.addPoint([x, y], true, false, true);
}, 1000);
}
}
},
xAxis: {
maxPadding: 1
}
I want to dynamically update data in a fix x-axis range such as 9:00 to 18:00,but when redrawing happened,the max value in x-axis will increase,how can i keep the value not changed?Just like a stock chart dynamically show the stock price.
My code: http://jsfiddle.net/cruelcage/ny43Z/
can someone help me?
Upvotes: 1
Views: 5307
Reputation: 19103
You can tell highcharts what the min and max values to plot on the y-axis:
yAxis: {
min:0,
max:1,
See the updated example http://jsfiddle.net/2ghdH/.
Yoo can do the same on the x-axis as well:
var end = (new Date()).getTime()+100000;
xAxis: {
type: 'datetime',
tickPixelInterval: 150,
maxPadding :1.5,
max:end
},
Upvotes: 3