This is the code for Chapter 1, Figure 27 from D3.js in Action showing simple data binding using a filtered array filler data to create elements with content based on the values of the datapoints.
<html>
<head>
<title>D3 in Action Chapter 1 - Example 6</title>
<meta charset="utf-8" />
<script src="//d3js.org/d3.v3.min.js" type="text/JavaScript"></script>
</head>
<style>
#vizcontainer {
width: 200px;
height: 100px;
border: 1px gray solid;
}
</style>
<body>
<div id="vizcontainer">
</div>
</body>
<footer>
<script>
var someNumbers = [17, 82, 9, 500, 40];
smallerNumbers = someNumbers.filter(function(el) {return el <= 40 ? this : null});
d3.select("body")
.selectAll("div")
.data(smallerNumbers)
.enter()
.append("div")
.html(function (d) {return d});
</script>
</footer>
</html>