Skip to content

Instantly share code, notes, and snippets.

Last active February 9, 2016 00:45
What would you like to do?
D3 and Custom Data Attributes
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<ul id="list">
<li data-username="shawnbot">Shawn Allen</li>
<li data-username="mbostock">Mike Bostock</li>
<script src="//"></script>
d3.selectAll("#list li")
.datum(function() { return this.dataset; })
.sort(function(a, b) { return d3.ascending(a.username, b.username); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment