Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change mouse cursor over vis.js network node

Is there a way to change the mouse cursor in vis.js when it's over a network node? I'm looking to treat them as links to the object the node represents and have been asked that the cursor change to the "finger" icon to indicate it can be clicked.

like image 310
Paul Dugas Avatar asked Nov 10 '16 16:11

Paul Dugas


3 Answers

for me its work with 3 steps

1.Fired if the option interaction:{hover:true} is enabled and the mouse hovers over a node.

  var options = { 
    physics: {
      enabled: false
    },
    interaction:
    {  hover:
        true
    }};

2.hoverNode Function

network.on("hoverNode", function (params) { network.canvas.body.container.style.cursor = 'pointer'; });

3.blurNode Function

 network.on("blurNode", function (params) {
        network.canvas.body.container.style.cursor = 'default';
 });
like image 121
Kelum Avatar answered Nov 04 '22 15:11

Kelum


For that purpose, first we attach hoverNode event of network that fires when we hover on any node of network.

network.on("hoverNode", function (params) {
        network.canvas.body.container.style.cursor = 'pointer'
 });

Then we bind blurNode event of network that fires when we bring house away (blur) from node. If we don't attach this event, you will see pointer on all over your network.

 network.on("blurNode", function (params) {
        network.canvas.body.container.style.cursor = 'default'
 });

you can see documentation for further details.

like image 29
Baqer Naqvi Avatar answered Nov 04 '22 16:11

Baqer Naqvi


Additionally, the hover flag must be set for interactions before the hoverNode event will fire:

var options = {interaction:{hover:true}};
like image 7
Graham Epps Avatar answered Nov 04 '22 16:11

Graham Epps