packed = {
let svgElement, svg;
[svgElement, svg] = getSVG();
const color = d3
.scaleOrdinal()
.domain(["a", "b", "c"])
.range(['green', 'orange', 'red']);
const cells = circles.map((d, i) => [d, voronoi.cellPolygon(i)]);
const num = circles.length;
const area = (d3.polygonArea(polygon) / num) * 0.8;
const center = d3.polygonCentroid(polygon);
const diameter = Math.sqrt(-area);
const elements = circles.map((d, i) => ({
x: coor[i][0],
y: coor[i][1],
r: d.count,
food: d.food
}));
svg
.append('path')
.data([polygon])
.attr('stroke', 'black')
.attr('fill', 'none')
.attr('d', d => d3.line()(d));
const root = pack(data);
const node = svg.selectAll("g")
.data(d3.group(root.descendants(), d => d.height))
.join("g")
.selectAll("g")
.data(d => d[1])
.join("g")
.attr("transform", d => `translate(${d.x + 1},${d.y + 1})`);
node.append("circle")
.attr("r", d => d.r)
.attr("fill", d => color(d.height));
const leaf = node.filter(d => !d.children);
leaf.select("circle")
.attr("id", d => (d.leafUid = DOM.uid("leaf")).id);
return svgElement
}