# d3: Scaling when there is a large amount of data can cause lag

**URL:** <https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526>\
**Category:** Help\
**Created:** [November 22, 2023, 7:07am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526 "2023-11-22T07:07:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![moon](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/moon/32/8216_2.png) [@moon](https://talk.observablehq.com/u/moon)\
**Post date:** [November 22, 2023, 7:07am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/1 "2023-11-22T07:07:03Z")

</div>

Hi  
I have implemented the scaling function using d3 and found that the scaling process is very slow, about more than a second. I would like to ask if it is the reason for my large data volume (70000), and is there any solution for optimization?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [November 22, 2023, 7:58am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/2 "2023-11-22T07:58:37Z")

</div>

Most probably the bottleneck would be SVG rendering; browsers start to lag when they have to display 10k or more nodes. A common solution is to render the chart with canvas instead of SVG.

---

<div class="post-metadata">

**Author:** ![moon](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/moon/32/8216_2.png) [@moon](https://talk.observablehq.com/u/moon)\
**Post date:** [November 22, 2023, 8:09am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/3 "2023-11-22T08:09:29Z")

</div>

Thank you for your answer. I would like to ask if you have any examples of canvas rendering with coordinate axes to share? Also, if I use canvas rendering, will the axes move when I zoom?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [November 22, 2023, 8:59am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/4 "2023-11-22T08:59:12Z")

</div>

the axes would still be rendered with svg, but the scatterplot would be in canvas

don’t hesitate to search  
[https://observablehq.com/search?query=zoom+canvas](https://observablehq.com/search?query=zoom+canvas)

---

<div class="post-metadata">

**Author:** ![moon](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/moon/32/8216_2.png) [@moon](https://talk.observablehq.com/u/moon)\
**Post date:** [November 22, 2023, 9:05am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/5 "2023-11-22T09:05:11Z")

</div>

Is there a way to optimize Zoom if I use plot. js to draw plots and d3 to achieve scaling?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [November 22, 2023, 1:02pm UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/6 "2023-11-22T13:02:41Z")

</div>

not yet, see [Panning and zooming · Issue #1590 · observablehq/plot · GitHub](https://github.com/observablehq/plot/issues/1590)

---

<div class="post-metadata">

**Author:** ![moon](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/moon/32/8216_2.png) [@moon](https://talk.observablehq.com/u/moon)\
**Post date:** [November 23, 2023, 1:25am UTC](https://talk.observablehq.com/t/d3-scaling-when-there-is-a-large-amount-of-data-can-cause-lag/8526/7 "2023-11-23T01:25:22Z")

</div>

ok , thanks.
