order() gets or sets the ordering strategy used by a D3 stack layout. Chaining it to the stack generator controls which series appear at the bottom, middle, and top of stacked bar charts, stacked area charts, and streamgraphs. section 5.2.4
D3 provides six built-in ordering strategies:
- stackOrderNone keeps the keys array order, from bottom to top. section 5.2.4
- stackOrderReverse reverses the keys array order. section 5.2.4
- stackOrderAscending places the series with the smallest total at the bottom. section 5.2.4
- stackOrderDescending places the series with the largest total at the bottom. section 5.2.4
- stackOrderAppearance orders series by when they reach their peak values. section 5.2.4
- stackOrderInsideOut places earlier-peaking series near the center and later-peaking series outside, supporting streamgraphs. section 5.2.4
Choose an order while configuring the stack
const stackGenerator = d3.stack() .keys(formatsInfo.map(f => f.id)) .order(d3.stackOrderInsideOut) .offset(d3.stackOffsetSilhouette);
