-
Notifications
You must be signed in to change notification settings - Fork 0
Stack Layout
The stack layout takes a two-dimensional array of data and computes a baseline; the baseline is then propagated to the above layers, so as to produce a stacked graph. Several baseline algorithms are supported, along with sorting heuristics to improve perception, as described in “Stacked Graphs – Geometry & Aesthetics” by Byron & Wattenberg.

The stack layout operates in an arbitrary two-dimensional x and y coordinate space, as with other layouts, including tree. Thus, layers can be stacked vertically, horizontally, or even radially. While the "zero" offset is the default, a streamgraph can be generated using the "wiggle" offset, which attempts to minimize change in slope weighted by layer thickness.
In the simplest case, the layer data can be specified as a two-dimensional array of numbers. The y and x accessors are used to define the thickness of each layer at the given position, respectively. With the exception of the "expand" offset, the stack layout does not perform any automatic scaling of data. To simplify scaling, use this layout in conjunction with a linear scale or similar. The stack layout currently requires that the layers are homogenous: each must contain the same number of values at the same x-coordinates. If your data is not so regular, you will need to reinterpolate the data before computing the stack.
# d3.layout.stack()
# stack(layers[, index])
# stack.values([accessor])
# stack.order([order])
- inside-out -
- reverse -
- default -
# stack.offset([offset])
- silhouette -
- wiggle -
- expand -
- zero -
# stack.x([x])
# stack.y([y])
# stack.out([out])