What makes the D3 an “empty” choice?

I am new to D3 and recently saw this piece of code while someone was creating a transition: d3.select({})in d3.select({}).transition(), etc. This is similar to the same as d3.select([]). In the console, it appeared as an array, but I'm still not sure what it does. Any help would be appreciated, thanks!

+4
source share
1 answer

The only thing I saw is here . Now usually you need the d3.selectobject for which you want to trigger the transition. But in a related example, Bostock does not work on svg, consisting of different DOM objects, to manipulate, but instead on a canvas that needs to be erased and redrawn for each transition step. So, d3.select({}).transition()it just becomes an easy way to start a shared transition with which it can work. It should be noted that to create a transition, you need to choose something, just the execution d3.select().transition()will not work, and an empty object (or an empty array) allows it to work.

+5
source

All Articles