InteractiveCube
InteractiveCube

Reputation: 160

Unable to fix position of two nodes in vis.js

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?

Upvotes: 1

Views: 1501

Answers (1)

cityy
cityy

Reputation: 163

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/

Upvotes: 2

Related Questions