chart = {
kmeans(data, clusters)
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("max-width", myWidth);
xScale.domain(d3.extent(data, d => d.x)).nice()
yScale.domain(d3.extent(data, d => d.y)).nice()
svg.append("g")
.call(xAxis)
.append("text")
.attr("x", myWidth)
.attr("y", margin.bottom - 4)
.attr("fill", "currentColor")
.attr("text-anchor", "end")
.text(x)
svg.append("g")
.call(yAxis)
.append("text")
.attr("x", -margin.left)
.attr("y", 10)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text(y)
svg.append("g")
.attr("stroke-width", 1.5)
.attr("fill", "none")
.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", d => xScale(d.x))
.attr("cy", d => yScale(d.y))
.attr("stroke", d => color(d.cluster))
.attr("r", 3);
return svg.node();
}