I have a drag behavior that looks like the following:
var boxDrag = d3.behavior.drag()
.origin(function (d) {
return d;
})
.on("drag", drawBox);
function drawBox( /*d*/ ) {
console.log("asdf");
}
It's only a temporary skeleton, and yet it seems to be pulling up some errors about undefined x's and such.
Errors
Here's the full code: http://jsfiddle.net/gamea12/5zsj853h/
In your fiddle, you have:
var boxDrag = d3.behavior.drag()
.origin(function (d) {
return d;
})
.on("drag", drawBox);
However, in this case, d
is undefined, which is causing your error. Changing this to:
var boxDrag = d3.behavior.drag()
.origin(function (d) {
return this;
})
.on("drag", drawBox);
Should fix the problem for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.