Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active Feb 9, 2016
Embed
What would you like to do?
Order
license: gpl-3.0
<!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