Last active
December 22, 2015 15:58
-
-
Save hoschi/6495727 to your computer and use it in GitHub Desktop.
testing deep selection and data grouping
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"> | |
<style> | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.js"></script> | |
<script> | |
var data = ['foo', 'bar'] | |
var main = d3.select('body').selectAll("div").data(data); | |
main.select('p').text(function(d){return d;}) | |
main.enter().append('div').append('p'); | |
data = ['lol', 'olo']; | |
main.data(data); | |
/* | |
main = d3.select('body').selectAll("div").data(data); | |
d3.select('body div p').text(function(d){return d;}); | |
// foo bar | |
d3.selectAll('body div p').text(function(d){return d;}); | |
// foo bar | |
d3.select('body div').selectAll('p').text(function(d){return d;}); | |
// foo bar | |
d3.select('body div').select('p').text(function(d){return d;}); | |
// lol bar (oookay?) | |
*/ | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment