Skip to content

Instantly share code, notes, and snippets.

@hoschi
Last active December 22, 2015 15:58
Show Gist options
  • Save hoschi/6495727 to your computer and use it in GitHub Desktop.
Save hoschi/6495727 to your computer and use it in GitHub Desktop.
testing deep selection and data grouping
<!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