2017-06-27 22 views
0

我試圖修復兩個節點的位置。 它們應該在y維上相互之間相距400px。無法修復vis.js中兩個節點的位置

var edges = [{ 
    id:"1", 
    fixed: {x:true, y:true}, 
    x:0,y:-200 
},{ 
    id:"2", 
    fixed: {x:true, y:true}, 
    x:0,y:200 
}, ...]; 

然而,位置不固定和漂移所有的地方。 這是相應的fiddle

任何想法?

回答

1

也許這種解決方法會爲你工作:

1)儲存節點和邊緣dataSets

2)設置節點位置上afterDrawing和更新dataSet

network.on('afterDrawing', function(){ 
    let data = [{id: 1, x: 0, y:-200}, {id:2, x:0, y:200}]; 
    nodesObj.update(data); 
    }); 

小提琴:http://jsfiddle.net/7juye694/