Bars Around a Circle
Twelve months around a circle, each a bar chart of four values. The months are bands of a polar chart, and each bar chart is a chart nested at its month. After G2.
js
const random = d3.randomUniform.source(d3.randomLcg(0.42))();
const months = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."];
const data = months.flatMap((month) => ["A", "B", "C", "D"].map((name) => ({month, name, value: random()})));
const renderer = cm.svg({width: 480, height: 480});
const root = cm.flow().renderer(renderer);
root
.data(d3.groups(data, (d) => d.month))
.transform(cm.encode, {x: ([month]) => month})
.transform(cm.spreadX, {domain: months})
.transform(cm.polar, {innerRadius: 0.7, x: {axis: true}})
.append(cm.g)
.data(([, rows]) => rows)
.transform(cm.encode, {x: "name", y: "value", fill: "name"})
.transform(cm.spreadX)
.transform(cm.plane, {width: 60, height: 60})
.add(cm.rect);
root.render();
document.body.append(renderer.node());