Search code examples
propertieshovernodesvis.jsedges

Vis.js: Can you show properties on hovering?


I know that hovering on a node can show the title property. But can I also show other properties? Also, how about doing the same for edges?

Thanks, Bob


Solution

  • You can use the title property on edges as well. and you will need to generate the title attribute before binding it to the network.

    var nodes = new vis.DataSet([
      { id: 1, label: "Node 1", title: 'generate text before binding the sets' },
      { id: 2, label: "Node 2" },
      { id: 3, label: "Node 3" },
      { id: 4, label: "Node 4" },
      { id: 5, label: "Node 5" }
    ]);
    
    // create an array with edges
    var edges = new vis.DataSet([
      { from: 1, to: 3, title: 'from 1 to 3' },
      { from: 1, to: 2, title: 'from one 2 two' },
      { from: 2, to: 4 },
      { from: 2, to: 5 },
      { from: 3, to: 3 }
    ]);
    

    see this example