This is the code for Chapter 10, Figure 5 from D3.js in Action showing how a layout like d3.layout.grid() can be used to create different graphical elements, in this case SVG rect elements instead of SVG circles as in earlier examples.
Modified http://d3js.org/colorbrewer.v1.min.js to a secure url
https://d3js.org/colorbrewer.v1.min.js
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js