Last active
December 15, 2015 14:29
-
-
Save campersau/5274509 to your computer and use it in GitHub Desktop.
d3 insert order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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