可能重复:
setInterval 会导致浏览器挂起吗?
我实现了 Highstock JS v1.1.4 图表来表示数据
图表代码:
chart = new Highcharts.StockChart({
chart: {
renderTo: 'highchartviewpanel',
events:{
load:function(){
setIntervalForhighchartdata();
}
}
},
rangeSelector: {
buttons: [{
count: 1,
type: 'minute',
text: '1M'
},{
count: 5,
type: 'minute',
text: '5M'
},
{
count: 15,
type: 'minute',
text: '15M'
}],
selected:0,
inputEnabled: false
},
navigator: {
height: 40,
xAxis: {
valueDecimals: 1
}
},
title: {
text: 'payment analysis',
floating: true,
align: 'right',
x: -20,
top: 20
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
second : '%H:%M:%S',
minute : '%H:%M',
hour: '%H',
day : '%b,%d',
week : 'b,%d',
month : '%Y,%b',
year : '%Y'
},
valueDecimals: 0
},
yAxis: [
{
title: {
text: 'item1'
},
height: 50,
lineWidth: 2
}, {
title: {
text: 'item2'
},
top: 90,
height: 50,
offset: 0,
lineWidth: 2
},{
title: {
text: 'item3'
},
top: 150,
height: 50,
offset: 0,
lineWidth: 2
}],
series: [{
name: 'item1',
data: item1data,
color:'blue'
},
{
name: 'item2',
yAxis: 1,
data: item2data,
color:'black'
},{
name: 'item3',
yAxis: 2,
data: item3data,
color:'red'
}]
});
}
setIntervalForhighchartdata() 是每 10 秒更新一次图表的函数,我的数据值基于时间间隔 xdata 是日期时间,ydata 是 1,2,3 的数据点 ....
图形更新时它会挂起浏览器