4 ms·
status_quo69's answer is great, just here to add a few thoughts. This is largely why I wanted to write a post like this - often "using d3.js" is what we think
by wattenberger 7y ago
status_quo69's answer is great, just here to add a few thoughts.
This is largely why I wanted to write a post like this - often "using d3.js" is what we think we need to do, but I wanted to show that most of the API is just utility functions. Here are the two modules devoted to manipulating the DOM:
https://wattenberger.com/blog/d3#manipulating-the-dom https://wattenberger.com/blog/d3#manipulating-the-dom
I recommend (and follow) that you render elements like you normally would, and use things like d3 scales or d3.line() to convert your data into the physical aspects that are needed. I find it really hacky to do it any other way. I want to explore more, but I did a quick test to see which is more performant (letting React render a scatter plot, or letting d3 render a scatter plot), and pure React was 4x faster:
https://twitter.com/Wattenberger/status/1123413424678027265 https://twitter.com/Wattenberger/status/1123413424678027265
Of course, this was just one example, but it agrees with my hypothesis.
I do have a whole chapter devoted to d3 + React (and one on d3 + Angular) that might be worth checking out. I think it largely comes down to understanding your tools and being able to pick the parts of d3 that will be most useful to you.