5

円をドラッグ可能にしようとしています。

var drag = d3.behavior.drag();
  drag.on("drag", function(d,i) {
      console.log(d);
      d.x += d3.event.dx;
      d.y += d3.event.dy;
      //This will change the center coordinates by the delta
      d3.select(this).attr("x", d.x).attr("y", d.y);
      //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 ] + ")"
      })
  })

ここにフィドルがあります

d右の赤い円のすべての動きに対してエラーをスローしますが、3、4、および 5 行目でそれが未定義であると言っているのはなぜですか?

4

2 に答える 2