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")
.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) + jitter()},${y(d.y) + jitter()})`
)
.call(g =>
g
.append("circle")
.attr("fill-opacity", 0.7)
.attr("fill", d => z(d[colorBy]))
.attr("r", 4)
.append("title")
.text(d => d.name)
);
return svg.node();
}