Skip to content

Streamgraph ​

The stacked areas of the unemployed by industry, with the wiggle offset of cm.stackY, which shifts each date's stack so that the layers flow, changing their slopes as little as it can. After Observable Plot's industry-unemployment-stream test.

js
const data = await d3.csv("/data/bls-industry-unemployment.csv", d3.autoType);

const renderer = cm.svg({width: 640, height: 400});
const root = cm.flow().renderer(renderer);

root
  .data(data)
  .transform(cm.encode, {x: "date", y: "unemployed", fill: "industry"})
  .transform(cm.stackY, {offset: "wiggle"})
  .transform(cm.plane)
  .add(cm.areaY);

root.render();
document.body.append(renderer.node());