-
-
Save adamgreenhall/3297039 to your computer and use it in GitHub Desktop.
D3 and Custom Data Attributes
This file contains hidden or 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> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.4.6"></script> | |
</head> | |
<body> | |
<ul id="list"> | |
<li data-username="shawnbot">Shawn Allen</li> | |
<li data-username="mbostock">Mike Bostock</li> | |
</ul> | |
<script type="text/javascript"> | |
d3.selectAll("#list li") | |
.map(function() { return this.dataset; }) | |
.sort(function(a, b) { return d3.ascending(a.username, b.username); }); | |
console.log( d3.selectAll("#list li").map(function() { return this.dataset; }) ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment