Donut in the Terminal
The catch of Lake A by species, as a donut in cm.polar, on the terminal renderer. Its arcs are filled cells; a cell is twice as tall as it's wide, so the donut is round as shown. Each wedge is labeled with cm.label: its count in the middle of the ring, in black or white for contrast, keeping the color of the cells under it, and its species outside.
js
const seafood = await d3.csv("/data/seafood.csv", d3.autoType);
const renderer = cm.terminal({width: 400, height: 400, units: "pixels"});
const root = cm.flow().renderer(renderer);
root
.data(seafood.filter((d) => d.lake === "Lake A"))
.transform(cm.encode, {x: "count", fill: "species"})
.transform(cm.stackX)
.transform(cm.polar, {innerRadius: 0.4})
.add(cm.arc)
.add(cm.label, {text: "count", position: "center", contrast: true})
.add(cm.label, {text: "species", position: "outside", padding: 12});
root.render();
document.body.append(renderer.node());