Skip to content

Instantly share code, notes, and snippets.

@mgarciaTT
Last active October 19, 2017 14:55
Show Gist options
  • Save mgarciaTT/da3787bbc8ea0c237eddbccdca5580e8 to your computer and use it in GitHub Desktop.
Save mgarciaTT/da3787bbc8ea0c237eddbccdca5580e8 to your computer and use it in GitHub Desktop.
02_workshop_binding data to elements
license: mit
<!DOCTYPE html>
<head>
<title>d3js workshop - data binding</title>
<script src="http://d3js.org/d3.v3.js"></script> <!-- import D3 library -->
</head>
<body>
<script type="text/javascript">
// Write your code here
// an empty selection - looking for instantiations of data
place_holder = d3.selectAll('div')
.data(['ben', 'elcin', 'ana', 'jonatan', 'byron'])
.enter()
.append('div')
place_holder.text (function(d, i) {return i + 1 + " " + d;});
// let's really use the data to fill each element
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment