I am trying to set some constraints in a way so that when the graph is panned(left, right, up, down), we limit it in a way so that the panning left, for example, would stop at the farthest node. LINK TO THE FIDDLE
PANNING LEFT SHOULD BEHAVE SIMILAR TO THIS:
PANNING UP SHOULD BEHAVE LIKE THIS:
simulation.on("end", simend);
function simend (){
var x = d3.extent(graph.nodes, function(node){
return node.x
}),
y = d3.extent(graph.nodes, function(node){
return node.y
})
zoom.translateExtent([[-x[1],-y[1]],[2*width-x[0],2*height-y[0]]])
}