Although autozoom is on, nodes keep moving out of view. Automatic zoom to keep all nodes in view does not happen.
My console shows this:
interaction: Object
panning: Object
resizing: Object
selection: Object
zooming: Object
autoZoom: true
autoZoomDuration: 500
autoZoomSize: 0.9
doubleClickZoom: 1.5
fingers: true
sensitivity: 1
wheel: true
I create nodes with this function
function graphDoubleClick(event){
$("#nodemenu").css("display", "none");
$("#linkmenu").css("display", "none");
if (event.clickNode && event.shiftKey){//test the click was on a node
chart.addData({
nodes:[{
"id":"n"+nextId,
"type":"unknown",
"x":event.chartX,
"y":event.chartY,
"loaded":true,
"style":{"label":"newNode"}
}],
links:[{
"id":"ll"+nextId,
from:event.clickNode.id,
to:"n"+nextId,
"style":{"label":"unknown"}
}]
});
nextId += 1;
}
else if (!event.clickNode && !event.clickLink && event.shiftKey){
chart.addData({
nodes:[{
"id":"n"+nextId,
"loaded":true,
"type":"unknown",
"x":event.chartX,
"y":event.chartY,
"style":{"label":"newNode"}
}]
});
nextId += 1;
};
}
What could cause this behaviour?
Default doubleClick action is zoom in and it internally disables auto zoom.
Add event.preventDefault() at the end of graphDoubleClick and you should be fine.
Or disable zoom on double click by setting settings.interaction.zooming.doubleClickZoom = 0.