Unable to fix position of two nodes in vis.js

做~自己de王妃 提交于 2021-01-28 10:23:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!