我们正在使用jquery ajax调用来渲染highcharts为im使用setInterval来渲染动态图表每1分钟我的cpu内存消耗更多几乎达到100%并且我在chrome中获取kill页面你能帮我解决如何解决它
function DataSiftGraph(){
$.ajax({
url: "ViewGraphServlet",
type: 'POST',
data:{"flag":true,"hrefValue":searchKeyGraph},
contentType:"application/x-www-form-urlencoded",
success: function (response) {
tweets=response.tweets;
for(var i=0;i<tweets.length;i++){
descArray[i]=tweets[i];
//alert(descArray[i]);
document.getElementById("detailedcs").innerHTML+= descArray[i]+'<br/>';
}
stopFlag=response.stopFlag;
//series.data.push(formattedTime,response.positiveCount);
//chart.series[0].data.push(formattedTime,response.positiveCount);
shift = chartSentiment.series[0].data.length > 20;
chartSentiment.series[0].addPoint([response.toDate,response.positiveCount],true,shift);
chartSentiment.series[1].addPoint([response.toDate,response.negativeCount],true,shift);
chartSentiment.series[2].addPoint([response.toDate,response.neutralCount],true,shift);
//alert("response.affectionCount" + response.affectionCount);
chartEmotion.series[0].addPoint([response.toDate,response.affectionCount],true,shift);
chartEmotion.series[1].addPoint([response.toDate,response.amusementCount],true,shift);
chartEmotion.series[2].addPoint([response.toDate,response.contentCount],true,shift);
chartEmotion.series[3].addPoint([response.toDate,response.enjoymentCount],true,shift);
chartEmotion.series[4].addPoint([response.toDate,response.angerCount],true,shift);
chartEmotion.series[5].addPoint([response.toDate,response.fearCount],true,shift);
chartEmotion.series[6].addPoint([response.toDate,response.humiliationCount],true,shift);
chartEmotion.series[7].addPoint([response.toDate,response.sadnessCount],true,shift);
},
error: function(response, ajaxOptions, thrownError) {
}
});
}
这是使用
的示例代码答案 0 :(得分:0)
您使用哪个版本的highcharts?如果您使用addPoint,在每个调用函数中,整个图表都会重新绘制,因此性能会有所提升。我建议将redraw设置为false(在addPoint函数中使用paratmetr),然后在添加所有点后重绘。