- d3.selectAll is more verbose than $() but in my opinion, that's not a bad thing as I try to minimize DOM selections anyways;
- transitions are another area where D3 really shines, for cases where you don't/can't use CSS transitions, like displaying a discreet popup status message.
- d3 data binding is oh so convenient, and that's where the real magic happens. Combined with a queueing system like postal.js, we pretty much have the same thinking model as React. The DOM is now an expression of the data, and D3's joins figure out what DOM elements need to be updated. It's slightly lower level than React, in that you specify what happens on enter/update/exit, but in terms of efficiency, it seems great (disclaimer: we haven't run benchmarks);
- if you happen to like CoffeeScript, D3 turns into a very elegant DSL that is consistent for DOM editing, styling and event handling. Here's a simple lightbox modal dialog:
lightbox.shell = d3.select "body"
.div "#shadebox"
.style "opacity", 0
.on "click", ->
lightbox.removeLightbox()
d3.event.stopPropagation()
lightbox.body = lightbox.shell.append "div"
.attr "id", "lightbox"
.on "click", -> d3.event.stopPropagation()
lightbox.showLightbox()
return lightbox.body
- we've added a `.div` function that's shorthand for d3.append and automatically adds an id and/or class, to feel a bit more like Jade;- one downside we found with D3 is that we can't just grab any jquery plugin and throw it in our app.