How do you snap to a grid after dragging is finished in d3?
I tried adding an event listener to the dragend
event and rounding the values, but it doesn't seem to work:
force.drag()
.on('dragend', function(d) {
d.fixed = false;
d.x = Math.round(d.x / 10) * 10;
d.y = Math.round(d.y / 10) * 10;
});