pie = (data, { value, ...options }) => {
const cs = d3.cumsum(data, (d) => d[value]);
const r = 360 / cs[cs.length - 1];
for (let i = 0; i < cs.length; ++i) cs[i] *= r;
for (const d of data)
return Plot.geo(
{
type: "GeometryCollection",
geometries: data.map((d, i) => {
const a = -(cs[i - 1] || 0);
const b = -cs[i];
return {
type: "Polygon",
...d,
coordinates: [
[
[0, 90],
[a, 0],
[(2 * a + b) / 3, 0],
[(a + 2 * b) / 3, 0],
[b, 0],
[0, 90]
]
]
};
})
},
{ ...options }
);
}