This is the code for Chapter 2, Figure 12 from D3.js in Action that creates rectangles with height based on the data bound to the selection. In this case, the rectangles all overlap each other because their X position is the same.
Last active
March 18, 2016 15:15
-
-
Save emeeks/cceabdb4ee0870eebf54 to your computer and use it in GitHub Desktop.
Ch. 2, Fig. 12 - D3.js in Action
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
<html> | |
<head> | |
<title>D3 in Action Chapter 2 - Example 2</title> | |
<meta charset="utf-8" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
</head> | |
<style> | |
svg { | |
height: 500px; | |
width: 500px; | |
border: 1px solid gray; | |
} | |
</style> | |
<body> | |
<div> | |
<svg> | |
</svg> | |
</div> | |
</body> | |
<footer> | |
<script> | |
d3.select("svg") | |
.selectAll("rect") | |
.data([15, 50, 22, 8, 100, 10]) | |
.enter() | |
.append("rect") | |
.attr("width", 10) | |
.attr("height", function(d) {return d}) | |
</script> | |
</footer> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment