Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 01:12
Show Gist options
  • Save mbostock/1696372 to your computer and use it in GitHub Desktop.
Save mbostock/1696372 to your computer and use it in GitHub Desktop.
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