chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
svg.append("g").call(grid);
svg
.append("g")
.attr("stroke-width", 1.5)
.attr("font-family", "sans-serif")
.attr("font-size", 10)
.selectAll("g")
.data(data)
.join("g")
.attr("transform", d => `translate(${x(d.x)},${y(d.y)})`)
.call(g =>
g
.append("path")
.attr("fill", d => color(d.category))
.attr("d", d => shape(d.category))
)
.call(g =>
g
.append("text")
.attr("dy", "0.35em")
.attr("x", 10)
.attr("fill", d => color(d.category))
.text(d => d.name)
);
return svg.node();
}