kee
kee

Reputation: 11629

How to extract a title of nodes in Network graph in Vis.js

I see this example at http://visjs.org/examples/network/events/interactionEvents.html.

I want to set up a onclick handler and I want to extract the title of the node (not limited to the ID such as 1, 2 and so on). I couldn't find a good example and I am wondering if anyone knows how?

Cheers, K

Upvotes: 0

Views: 1625

Answers (1)

cityy
cityy

Reputation: 163

You might want to look at the following parts of the documentation:


    network.on('select', function(selection){
      let selectedNodeIds = selection.nodes; // array of selected node's ids
      let selectedNodes = nodes.get(selectedNodeIds); // retrive node objects from dataSet object
      let selectedNodesLabels = [];
      for( let i in selectedNodes ) {
        selectedNodesLabels.push(selectedNodes[i].label);
      }
    });

Upvotes: 1

Related Questions