Accepted answer

The problem is that you're not dealing with a mouse event (which has x and y properties set), but a mouse event wrapped in a drag event. You can access the source event through .sourceEvent:"cx", d[0] = d3.event.sourceEvent.x)
               .attr("cy", d[1] = d3.event.sourceEvent.y);

I've also changed the assignment to d to be consistent with how it's done to start with. Complete demo here.

Related Query

More Query from same tag