Closed cmflynn closed 5 years ago
Having the same issue, I just updated the Dataset of VIS NETWORK using
network.setData({nodes:nodes, edges:edges});
and everything is redrawn again. This should not happen. VisJS is very easy and good but this feature is a must.
Is there any activity in visjs to add this kind of feature?
Yes. If physics is disabled the layout doesn't get recalculated automatically.
The best way is just to call network.stabilize()
.
I really want the layout to remain the same after I update the labels of these nodes to the user doesn't see the entire network redraw.
You could go through all your nodes and save the x,y position of each node and than reset the positions the physics-engine calculated after changing node. As I see it the network can not know what you changes so it needs to be stabilized again.
I have a network graph which is in a hierachical layout with physics: true to initially space the nodes. After its been drawn, i disable physics via the "stabilizationIterationsDone" event. At this point it looks like this:![image](https://user-images.githubusercontent.com/18743297/49534168-e670d980-f88e-11e8-967f-743fba935693.png)
Next, I run a function in the background which builds a new Dataset of nodes(this is only to add an extra string to the label), and then i update via Dataset.update(). Now it looks like this:![image](https://user-images.githubusercontent.com/18743297/49534235-0dc7a680-f88f-11e8-92f6-7a6915282f4f.png)
This squashes all the nodes together which can only be fixed by either calling network.stabilize() or by leaving physics: true, so it will re stabilize automatically.
My question is, is this expected behavior? I really want the layout to remain the same after I update the labels of these nodes to the user doesn't see the entire network redraw.
I'm using Chrome Version 70.0.3538.110 (Official Build) (64-bit).