block by emeeks adebad9e7d73a4a3c15b

Ch. 2, Fig. 15 - D3.js in action

Full Screen

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.

index.html