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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With