Stacked Area in the Terminal
The revenue of recorded music in the US by format, summed per year with cm.groupX and stacked with cm.stackY, on the terminal renderer: each group of formats is an area of color, with a legend at the top.
js
const data = await d3.csv("/data/riaa-us-revenue.csv", d3.autoType);
const renderer = cm.terminal({width: 640, height: 400, units: "pixels"});
const root = cm.flow().renderer(renderer);
root
.data(data)
.transform(cm.encode, {x: "year", y: "revenue", fill: "group"})
.transform(cm.groupX, {y: "sum"})
.transform(cm.stackY)
.transform(cm.plane, {y: {grid: true, label: "revenue (millions)"}, fill: {legend: true}})
.add(cm.areaY);
root.render();
document.body.append(renderer.node());