[英]performance with jsflot, html5 canvas and setInterval
I am developing a webpage which has 9 jQuery Flot graphs which are updated with 我正在开发一个网页,其中包含9个更新的jQuery Flot图
setInterval(function(){
updateGraph1to8(data1);
}, 10);
setInterval(function(){
updateGraph9(data2);
}, 10);
and three HTML5 canvas which instead is updated on an event. 和三个HTML5画布,而不是在事件上更新。 Two of them are based on
data1
so they are drawn inside the event function that supply data1
like: 其中两个基于
data1
因此它们被绘制在提供data1
的事件函数中,如:
onData1available(){
//do math and stuff
updateCanvas1();
updateCanvas2();
}
while the remaining is based on data2
and is drawn in the same way. 其余的基于
data2
并以相同的方式绘制。
JS Flot graphs are drawn constantly as soon as the document is ready, they have no lag at all. 文档准备就绪后,JS Flot图表会不断绘制,它们完全没有滞后。 By the time I activate the canvas (the drawing is activated when a button is pressed), I notice a clear lag in the Flot graphs but none in the canvas.
当我激活画布时(按下按钮时图形被激活),我注意到Flot图形中的明显滞后但画布中没有。 I tried to move the Flot graphs drawing in the event function but everything was lagging as hell.
我试图在事件功能中移动Flot图形,但一切都落后了。 Then I tried to bring the canvases in a timer but it didn't really change anything.
然后我试着将画布带到计时器中,但它并没有真正改变任何东西。 My questions are:
我的问题是:
SOLUTION: 解:
SOLUTION: 解:
Solved using window.requestAnimationFrame trick 使用window.requestAnimationFrame技巧解决了问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.