This example shows how d3.nest and d3.layout.stack can be used in conjunction. This forms the basis for a stacked bar chart. This is example 16 from the screencast Splitting Charts.
MIT License
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js