Copy codeThe Code is as follows:
$ (Function (){
$ (Document). ready (function (){
Highcharts. setOptions ({
Global :{
UseUTC: false
}
});
Var chart;
$ ('# Iner'). highcharts ({
Chart :{
Type: 'spline ',
Animation: Highcharts. svg, // don't animate in old IE
MarginRight: 10,
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. random ();
Series. addPoint ([x, y], true, true );
},1000 );
}
}
},
Title :{
Text: 'Live random data'
},
XAxis :{
Type: 'datetime ',
TickPixelInterval: 150
},
YAxis :{
Title :{
Text: 'value'
},
PlotLines :[{
Value: 0,
Width: 1,
Color: '#000000'
}]
},
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: (function (){
// Generate an array of random data
Var data = [],
Time = (new Date (). getTime (),
I;
For (I =-19; I <= 0; I ++ ){
Data. push ({
X: time + I * 1000,
Y: Math. random ()
});
}
Return data;
})()
}]
});
});
});