Skip to content

Instantly share code, notes, and snippets.

@campersau
Last active December 15, 2015 14:29
Show Gist options
  • Save campersau/5274509 to your computer and use it in GitHub Desktop.
Save campersau/5274509 to your computer and use it in GitHub Desktop.
d3 insert order
<ul></ul>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script>
d3.select("ul").selectAll("li").data(d3.range(2, 5), identity).enter()
.append("li")
.text(identity);
d3.select("ul").selectAll("li").data(d3.range(0, 8), identity).enter()
.insert("li", function(d, i) {
return this.querySelector("li:nth-child(" + (i + 1) + ")");
})
.text(identity);
function identity(d) { return d; }
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment