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