Created
December 17, 2011 21:19
-
-
Save micahasmith/1491435 to your computer and use it in GitHub Desktop.
d3.js enter example
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
//so there's two divs on the page for this to select | |
d3.select('body') | |
.selectAll('div') | |
.data(["hello","there","world"]) | |
//this will map "hello" and "there" to the only two divs | |
.html(function(d){return d;}) | |
//but theres 3 pieces of data...? | |
//this is why d3 has the enter() function | |
//think of it as "withTheLeftOverDataAfterMapping()" instead of "enter()" | |
.enter() | |
//so now we can do something with the leftover data, | |
//how about create another div? | |
.append('div') | |
.html(function(d){return d;}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment