Last active
February 9, 2016 01:12
-
-
Save mbostock/1696372 to your computer and use it in GitHub Desktop.
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
license: gpl-3.0 |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<ul> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var data = [ | |
["A", "B", "C", "D", "E"], | |
["B", "C", "D", "A", "E"], | |
["C", "A", "D", "E", "B"], | |
["D", "A", "B", "E", "C"], | |
["E", "D", "B", "C", "A"] | |
]; | |
var li = d3.select("ul").selectAll("li") | |
.data(data[0]) | |
.enter().append("li") | |
.text(function(d) { return d; }) | |
.on("click", reorder); | |
function reorder(d, i) { | |
li | |
.data(data[i], function(d) { return d; }) | |
.order(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment