Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Edge Dynamically visjs

Tags:

vis.js

Can anyone help me with adding edges dynamically in this visjs network? Actually, I am trying to use drag and drop to add nodes to the canvas, but I need help adding edges when I click the node and add edge dynamically to another node existing on canvas.

like image 715
Dinesh K Avatar asked Sep 26 '16 11:09

Dinesh K


1 Answers

You can use the vis.js 'update' function to add either nodes or edges dinamycally. You simply pass in an array with the set of either nodes or edges that you are trying to add. You call it like this:

nodes.update(updateNodesArray)

OR

edges.update(updateEdgesArray)

where nodes and edges are the vis.DataSet instances that you originally created for the network.

Full docs can be found at https://visjs.github.io/vis-data/data/dataset.html

like image 159
pgoldweic Avatar answered Sep 19 '22 18:09

pgoldweic