Stacked Bars in the Terminal
The catch of six lakes by species, stacked with cm.stackY, on the terminal renderer. The legend's labels are measured by the terminal, a cell per character, so they line up.
js
const seafood = await d3.csv("/data/seafood.csv", d3.autoType);
const renderer = cm.terminal({width: 640, height: 400, units: "pixels"});
const root = cm.flow().renderer(renderer);
root
.data(seafood)
.transform(cm.encode, {x: "lake", y: "count", fill: "species"})
.transform(cm.spreadX)
.transform(cm.stackY)
.transform(cm.plane, {fill: {legend: true}})
.add(cm.rect);
root.render();
document.body.append(renderer.node());