by andrewstuart2 · 10y ago · 0 comments
- vs -
Declaring 'how' this structure is created
selection.enter().append("div").attr("class", "bar") .style("height", function(d){ return d + "px"; }) .style(“margin-top”, function(d){ return (100 — d) + "px"; });
enter is not imperative, but what you write just afterwards is.
It's an active verb and seems to imply an imperative style. Except it's actually declarative. The problem with d3 is that it takes a declarative system and gives it an imperative-looking API.
If I write "node.enter()" it definitely looks like I'm making the node is being made to enter if you aren't well-versed in d3.