Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Last active March 26, 2016 04:55
Show Gist options
  • Save StevenJL/9cd15190a8ced02a22e0 to your computer and use it in GitHub Desktop.
Save StevenJL/9cd15190a8ced02a22e0 to your computer and use it in GitHub Desktop.
d3.selectAll("div") // Returns selection.
.data(someData) // Bind each element in the selection to each element in `someData` array.
.enter() // The `enter` function defines what to do with the extra data not represented as a `div`.
.append("div") // In this case, you append a new div for every data that is not represented by a `div`.
.html("Wow") // with the html "Wow",
.append("span") // followed by a span,
.html("More Wow") // with more html.
.style("font-weight", "900"); // Applies style to the very last result, which in this case, is the html "More Wow".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment