This is a small code example that shows what d3.layout.stack does. It adds y and y0 properties to your data, where y0 is the cumulative sum of y values. This is example 11 from the screencast Splitting Charts.
MIT License
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js