问题
I am trying to fix the position of two nodes. They should be on top of each other, 400px apart in the y-dimension.
var edges = [{
id:"1",
fixed: {x:true, y:true},
x:0,y:-200
},{
id:"2",
fixed: {x:true, y:true},
x:0,y:200
}, ...];
However, the position are not fixed and wander all over the place. This is the corresponding fiddle.
Any ideas?
回答1:
Maybe this workaround will work for you:
1) store nodes and edges in dataSets
2) set node positions on afterDrawing
and update the dataSet
network.on('afterDrawing', function(){
let data = [{id: 1, x: 0, y:-200}, {id:2, x:0, y:200}];
nodesObj.update(data);
});
fiddle: http://jsfiddle.net/7juye694/
来源:https://stackoverflow.com/questions/44786335/unable-to-fix-position-of-two-nodes-in-vis-js