liveBook · Manning

D3.stackOrderInsideOut

As explained in D3.js in Action, Third Edition

d3.stackOrderInsideOut is a D3 stack ordering constant that places early-peaking series near the center and late-peaking series toward the outside.

d3.stackOrderInsideOut is a D3 stack ordering constant. It places series with the earliest peak near the chart’s center and series with later peaks toward the outside, producing a visually balanced arrangement. section 5.2.4

Use this order when:

  • Building a streamgraph whose shapes should distribute around a central baseline. section 5.2.4
  • Combining order() with an offset() such as d3.stackOffsetSilhouette to control both stacking sequence and baseline position. section 5.2.4

Configure a centered streamgraph

const stackGenerator = d3.stack() .keys(formatsInfo.map(f => f.id)) .order(d3.stackOrderInsideOut) .offset(d3.stackOffsetSilhouette); section 5.2.4

Figure 5.19 D3 allows controlling the order in which the shapes are stacked with the order() accessor function. Here we see examples with stacked areas, but the same principles apply to stacked bar charts.
figure

Compare how different order() choices change the arrangement of stacked areas; the same ordering principles apply to stacked bars. section 5.2.4

How D3.js in Action, Third Edition covers it

How deep it goes
Defines peak-based placement and contrasts it with appearance, ascending, and descending orders without detailing its calculation.
Examples
Uses a D3 stack generator with d3.stackOrderInsideOut and d3.stackOffsetSilhouette for a streamgraph configuration.
What you can do after
Apply it via D3 to order stacked series and pair the result with an offset suited to the intended chart.
How it connects
Connects stack order to streamgraphs, stacked areas, stacked bar charts, stack offsets, and central baselines.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.