I have this code for configuring a path that surrounds some elements, the path is named cluster:
cluster
.data(getData()).enter()
.append("path") // notice SVG path elements
//...
.call(d3.behavior.drag()
.on("drag", function (d, i) {
d.x += d3.event.dx
d.y += d3.event.dy
console.log("d3.event.dx", d3.event.dx) //prints a number
cluster.attr("transform", function (d, i) {
return "translate(" + d3.event.dx +", "+ d3.event.dy + ")"
})
}));
Everything is working except the dragging functionality for cluster path.
Shouldn't it be dx
instead of d3.event.dx
(likewise for y
)?
cluster.attr("transform", function (d, i) {
return "translate(" + d.x + ", "+ d.y + ")"
})
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.