Skip to main content
100%

Simple Stack

✓ Published0🌍 Public
Aanotherjavadude
Last edited Jun 16, 2012
Created on Jun 16, 2012

This stacked bar chart displays five categories with three series each, using a simple matrix as its data source. The code relies on d3.layout.stack() to transform the raw matrix into stacked values, then renders rectangles via d3.scale.ordinal for x-positions, d3.scale.linear for heights, and a color scale for series. Console logs expose the matrix-to-stack transformation process, while SVG groups and rects are positioned with negative y-coordinates to build the upward stack from a baseline.

AI-generated description

Starting from Mike's sample (https://gist.github.com/1134768) I stripped down the chart to the bare minimum to understand the physics. I use a matrix instead of a csv or json. With the console.log outputs you can look at the transformation of the matrix when fed into the stack layout.

Similar vizzes