chart = {
let color = muzli[Palette];
let seed = seededRandom(randomSeeds);
let simulation = d3
.voronoiMapSimulation(data_0)
.initialPosition(d3.voronoiMapInitialPositionPie())
.weight((d) => d.weight)
.prng(seed)
.clip(ellipse)
.stop();
function ticked() {
let state = simulation.state();
while (!state.ended) {
simulation.tick();
state = simulation.state();
}
let polygons = state.polygons;
const cell = svg
.selectAll(".cell")
.data(polygons)
.join("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.attr("class", "cell");
cell
.selectAll("path")
.data((d) => [d])
.join("path")
.attr("d", (d, i) => {
d.area = d3.polygonArea(d);
return drawRoundedPolygon(d, area_scale(d.area));
})
.attr("fill", (d, i) => {
return color[randInt(5)];
})
.attr("stroke", "white")
.attr("stroke-width", 10);
}
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height + 100]);
svg
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.append("circle")
.attr("cx", 300)
.attr("cy", 300)
.attr("r", 310)
.attr("stroke", "lightgrey");
ticked()
return svg.node();
}