{
function dragged(d) {
d3.select(this)
.attr("cx", d[0] = d3.event.x)
.attr("cy", d[1] = d3.event.y);
path.attr("d", line(hull(svg.selectAll("circle").data())));
}
const svg = d3.select(DOM.svg(width, height));
const path = svg.append("path")
.attr("fill", "steelblue")
.attr("stroke", "steelblue")
.attr("stroke-width", 16)
.attr("opacity", 0.2)
.attr("d", hullPath);
svg.selectAll("circle").data(points)
.enter().append("circle")
.style("cursor", "grab")
.attr("fill", "steelblue")
.attr("cx", d => d[0])
.attr("cy", d => d[1])
.attr("r", 4)
.call(d3.drag()
.on("start", function () { d3.select(this).style("cursor", "grabbing"); })
.on("end", function () { d3.select(this).style("cursor", "grab"); })
.on("drag", dragged));
return svg.node();
}