Nightingale Entrance
The causes of mortality over a year, stacked by month in polar coordinates. The types enter one after another and their wedges 200ms apart, each opening like a wheel from its start angle for 600ms: cm.stackEnter encodes the timing of the transition as data. After Canis.
js
const data = await d3.csv("/data/nightingale.csv", d3.autoType);
const renderer = cm.svg({width: 640, height: 640});
const root = cm.flow({transition: true}).renderer(renderer);
function draw() {
root
.data(data)
.transform(cm.encode, {x: "Month", y: "Death", fill: "Type"})
.transform(cm.spreadX, {sort: false})
.transform(cm.stackY, {reverse: true})
.transform(cm.stackEnter, {step: 200, duration: 600, reverse: true})
.transform(cm.polar, {
x: {axis: true},
fill: {
domain: ["Disease", "Wounds", "Other"],
range: ["rgb(251, 106, 74)", "rgb(107, 174, 214)", "rgb(150, 150, 150)"],
legend: true,
},
})
.add(cm.arc, {stroke: "white", appear: true, enter: {sweep: 0}});
}
// Draws the chart, so that its intro plays, then clears it, so that its wedges exit, and draws it
// again, so that they enter.
function play() {
draw();
root.render();
root.finished().then(() =>
setTimeout(() => {
root.clear().render();
root.finished().then(() => setTimeout(play, 300));
}, 1500),
);
}
play();
document.body.append(renderer.node());