3 ms·
If you skip the whole .enter() pattern then D3 is more approachable, IMHO.
by th0ma5 10y ago
If you skip the whole .enter() pattern then D3 is more approachable, IMHO.
- dlbucci 10y ago.enter() was sort of confusing for me at first, but you lose the data-binding goodness of D3 if you drop it. I think the real issue is that the tutorials don't really explain it correctly: .enter() is where you add things and make changes that will be with the nodes for their lifetime. Do that, and then do your update logic (setting path attributes & fills, etc.). Don't run update logic when instantiating nodes, except for animation.
- athenot 10y agoYou can think of .enter() as React working in 1 way and under your explicit control instead of automagically. It's a one-way binding between your data and your DOM, with the data being the source of truth.
- Hupriene 10y agod3v4 is improving the logic around .enter() a bit. See https://medium.com/@mbostock/what-makes-software-good-943557f8a488 https://medium.com/@mbostock/what-makes-software-good-943557... Search for "Removing the magic of enter.append"
- vanderZwan 10y agoYou can also use Vega or Vega-Lite and let d3 be the low-level architecture: http://vega.github.io/ http://vega.github.io/ https://www.youtube.com/watch?v=Y8Fp9z-9DWc https://www.youtube.com/watch?v=Y8Fp9z-9DWc https://vimeo.com/177767802 https://vimeo.com/177767802 I especially like how they handle interaction (event streams/signals; about six, seven minutes into the youtube video). Supposedly there's a big update coming late fall, that upgrades vega and vega-lite to the latest version of D3. It also (finally) introduces the interactive bits to vega-lite.