If not posible with vis.js, I could do the entire thing on something else. But this functionality is crucial. So, show everything if nothing selected; show only children (with the "from" arrow) of some node if that node is selected. Or to select the node in some list, or type it somewhere. https://codepen.io/andre-fr-silva/pen/ZEBPpqK
var container = document.getElementById("mynetwork");
var data = {
nodes: nodes,
edges: edges,
};
Direct Decendents
This can be achieved using the select event defined in the documentation here in combination with the hidden property on nodes defined here. You can update the data in the DataSet, the network will then display the updates. In summary the logic I would suggest is to:
The following implements this logic.
Please note this could be optimised further, removing or updating items in the
nodesToUpdatearray instead of duplicating them.All Decendents
A similar approach can be used to show all dependents. Using recursion is the easiset way to achieve this, with checks to make sure the code doesn't get caught in am endless loop (if one exists in the network). In the sample code below a new function named
addChildNodesis declared that is called recursively to add each nodes children as the edges are followed.