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("path")
.data(data)
.join("path")
.attr("transform", d => `translate(${x(d.x)},${y(d.y)})`)
.attr("fill", d => color(d.category))
.attr("d", d => shape(d.category));
return svg.node();
}