This is the code for Chapter 2, Figure 22 from D3.js in Action that nests data using d3.nest() and then represents the nested data as a bar chart by first computing the length of the nested data arrays and using that length to size the bars by.
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js