Skip to content

Instantly share code, notes, and snippets.

@Andrew-Reid
Created April 12, 2018 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrew-Reid/539c8ee99cbbabbf15b81ae1f5abb3e1 to your computer and use it in GitHub Desktop.
Save Andrew-Reid/539c8ee99cbbabbf15b81ae1f5abb3e1 to your computer and use it in GitHub Desktop.
selection.call logging
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.js"></script>
</head>
<body>
<script type="text/javascript">
var dataset = d3.range(10);
d3.select("body").selectAll("div")
.call(log,"body")
.data(dataset)
.call(log,"dataset")
.enter()
.call(log,"enter")
.append("div")
.call(log,"div")
.attr("class", "bar")
.call(log,"bar");
function log(sel,msg) {
console.log(msg,sel);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment