chart = {
const context = DOM.context2d(width, height);
const canvas = context.canvas;
function render() {
context.clearRect(0, 0, width, height);
circles.forEach((d) => {
context.beginPath();
context.moveTo(xScale(d.xValue) + radius, yScale(d.yValue));
context.arc(xScale(d.xValue), yScale(d.yValue), radius, 0, 2 * Math.PI);
context.fillStyle = d.color;
context.fill();
if (d.active) {
context.lineWidth = 2;
context.stroke();
}
});
}
d3.select(context.canvas).call(
drag(circles).on("start.render drag.render end.render", render)
);
render();
return canvas;
}