[英]Should I use transform instead of redraw?
I have several charts I do redraw everytime I zoom/pann using d3 brushes. 我有几张图表,每次使用d3笔刷缩放/平移时都会重绘。
But, when I have tons of rendered elements, redrawing starts to be a little bit slow. 但是,当我有大量的渲染元素时,重画开始有点慢。
Instead of redrawing all elements everytime I move my brush, I was wondering whether or not it's feasible to transform (translate) the already drawn elements, and only redraw whenever I need to update my data. 我想知道是否可以转换(翻译)已经绘制的元素,并且仅在需要更新数据时才重新绘制,而不是每次移动画笔时都重新绘制所有元素。
I think it would increase my visualization performance a lot whenever panning to right/left, wouldn't it ? 我认为无论何时左右移动都可以大大提高我的可视化性能,不是吗?
Any insights ? 有什么见解吗?
In general, the less you touch the DOM the better your performance will be. 通常,您触摸DOM的次数越少,性能就会越好。 The details are browser and platform specific, but in general this is the pecking order of performance at a very high level (ordered from most expensive to least):
详细信息是特定于浏览器和平台的,但总的来说,这是性能从高到低的顺序(从最贵到最少):
So if you can get the result you want by simply modifying a targeted subset of existing elements with a transform attribute, I would guess you will be much better off. 因此,如果您可以通过简单地使用transform属性修改现有元素的目标子集来获得所需的结果,我想您的情况会更好。
Of course, it's impossible to say anything with certainty without seeing the actual code and use case. 当然,没有看到实际的代码和用例就不可能确定地说什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.