I am trying to make a circle draggable.
var drag = d3.behavior.drag(); drag.on("drag", function(d,i) { console.log(d); dx += d3.event.dx; dy += d3.event.dy; //This will change the center coordinates by the delta d3.select(this).attr("x", dx).attr("y", dy); //This should change the upper left x and y values by the delta d3.select(this).attr("transform", function(d,i){ return "translate(" + [ x,y ] + ")" }) })
Here is the fiddle
It gives errors for each movement on the right red circle, but why does it say that d is undefined on lines 3, 4 and 5?
source share