d3js: Create an HTML select box using d3.js
Created
September 27, 2013 19:51
-
-
Save jfreels/6734245 to your computer and use it in GitHub Desktop.
d3js: Create an HTML select box using d3.js
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'> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<link rel='stylesheet' href='style.css'> | |
</head> | |
<body> | |
<script type='text/javascript' src='script.js'></script> | |
</body> | |
</html> |
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
var data = ["Option 1", "Option 2", "Option 3"] | |
var select = d3.select('body').append('select') | |
var options = select | |
.selectAll('option') | |
.data(data).enter() | |
.append('option') | |
.text(function (d) { return d; }); |
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
/* CSS Here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment