In the vis javascript library, how do I get the node from its node Id?

srayner picture srayner · Aug 6, 2015 · Viewed 12.9k times · Source

So I create the nodes like this...

var nodes = new vis.DataSet([
    {id: 1, label: 'Peter'},
    {id: 2, label: 'John'},
    {id: 3, label: 'Sally'},
]);

then later on in an event handler after clicking on a node I get the id of the node i clicked. How do I get node object from its id?

Answer

srayner picture srayner · Aug 7, 2015

I actually found the documentation here; http://visjs.org/docs/data/dataset.html

node = nodes.get(nodeId);