This is the code for Chapter 2, Figure 15 from D3.js in Action that creates rectangles with height based on the data bound to the selection. The rectangles are positioned along the X axis based on the array position of the datapoint that each retangle represents and each rectangle is offset based on its height so as to be drawn as a typical bar chart. This offsetting is necessary with SVG rectangles because they are drawn down from their XY position.
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js