Why don't my node hover popups work in my vis.js network?











up vote
1
down vote

favorite












I am having an issue where despite including the 'title' property in my node objects, when I hover over a node, no pop up window with the contents of my title are displayed.



Here are my options and how I set my network up.



setUpNetwork(){
let container = document.getElementById('mynetwork');
//These options dictate the dynamic of the network
let options = {
nodes: {
shape: 'box'
},
interaction: {
dragNodes: false,
dragView: false,
hover: true
},
layout: {
randomSeed: undefined,
improvedLayout: true,
hierarchical: {
enabled: true,
levelSeparation: 180,
nodeSpacing: 180,
edgeMinimization: true,
parentCentralization: true,
direction: 'UD', // UD, DU, LR, RL
sortMethod: 'directed' // hubsize, directed
}
},
physics: {
enabled: false
}
}
// initialize your network!
this.network = new vis.Network(container, this.data, options);
}


When I add a node to my list of nodes for my network, this is my structure:



addNode(node: any){
try {
this.data.nodes.add({
id: node.id,
color: node.color,
title: node.title,
label: node.label
});
this.network.fit();
}
catch (err) {}
}


The environment that I'm running my code from makes it difficult to provide an example of this issue live. Everything else in the network works just fine (label, id, color), just not the title when I hover over a node.



EDIT:



I copied this code from this example from vis.js where pop ups are working.



// create an array with nodes
var nodes = new vis.DataSet([
{id: 1, label: 'Node 1', title: 'I have a popup!'},
{id: 2, label: 'Node 2', title: 'I have a popup!'},
{id: 3, label: 'Node 3', title: 'I have a popup!'},
{id: 4, label: 'Node 4', title: 'I have a popup!'},
{id: 5, label: 'Node 5', title: 'I have a popup!'}
]);

// create an array with edges
var edges = new vis.DataSet([
{from: 1, to: 3},
{from: 1, to: 2},
{from: 2, to: 4},
{from: 2, to: 5}
]);

// create a network
var container = document.getElementById('mynetwork');
var data = {
nodes: nodes,
edges: edges
};
var options = {interaction:{hover:true}};
this.network = new vis.Network(container, data, options);


I tried using only this in my environment; however, the popups don't show up like in the example. I know my hovering event works because I included this code to print to console when I hover over a node:



this.network.on("showPopup", function (params) {
console.log("DO SOMETHING");
})


Is there some options setting that I'm missing here? Could there be some other issue as to why my hover popups don't show despite including the "title" property in my node objects?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I am having an issue where despite including the 'title' property in my node objects, when I hover over a node, no pop up window with the contents of my title are displayed.



    Here are my options and how I set my network up.



    setUpNetwork(){
    let container = document.getElementById('mynetwork');
    //These options dictate the dynamic of the network
    let options = {
    nodes: {
    shape: 'box'
    },
    interaction: {
    dragNodes: false,
    dragView: false,
    hover: true
    },
    layout: {
    randomSeed: undefined,
    improvedLayout: true,
    hierarchical: {
    enabled: true,
    levelSeparation: 180,
    nodeSpacing: 180,
    edgeMinimization: true,
    parentCentralization: true,
    direction: 'UD', // UD, DU, LR, RL
    sortMethod: 'directed' // hubsize, directed
    }
    },
    physics: {
    enabled: false
    }
    }
    // initialize your network!
    this.network = new vis.Network(container, this.data, options);
    }


    When I add a node to my list of nodes for my network, this is my structure:



    addNode(node: any){
    try {
    this.data.nodes.add({
    id: node.id,
    color: node.color,
    title: node.title,
    label: node.label
    });
    this.network.fit();
    }
    catch (err) {}
    }


    The environment that I'm running my code from makes it difficult to provide an example of this issue live. Everything else in the network works just fine (label, id, color), just not the title when I hover over a node.



    EDIT:



    I copied this code from this example from vis.js where pop ups are working.



    // create an array with nodes
    var nodes = new vis.DataSet([
    {id: 1, label: 'Node 1', title: 'I have a popup!'},
    {id: 2, label: 'Node 2', title: 'I have a popup!'},
    {id: 3, label: 'Node 3', title: 'I have a popup!'},
    {id: 4, label: 'Node 4', title: 'I have a popup!'},
    {id: 5, label: 'Node 5', title: 'I have a popup!'}
    ]);

    // create an array with edges
    var edges = new vis.DataSet([
    {from: 1, to: 3},
    {from: 1, to: 2},
    {from: 2, to: 4},
    {from: 2, to: 5}
    ]);

    // create a network
    var container = document.getElementById('mynetwork');
    var data = {
    nodes: nodes,
    edges: edges
    };
    var options = {interaction:{hover:true}};
    this.network = new vis.Network(container, data, options);


    I tried using only this in my environment; however, the popups don't show up like in the example. I know my hovering event works because I included this code to print to console when I hover over a node:



    this.network.on("showPopup", function (params) {
    console.log("DO SOMETHING");
    })


    Is there some options setting that I'm missing here? Could there be some other issue as to why my hover popups don't show despite including the "title" property in my node objects?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am having an issue where despite including the 'title' property in my node objects, when I hover over a node, no pop up window with the contents of my title are displayed.



      Here are my options and how I set my network up.



      setUpNetwork(){
      let container = document.getElementById('mynetwork');
      //These options dictate the dynamic of the network
      let options = {
      nodes: {
      shape: 'box'
      },
      interaction: {
      dragNodes: false,
      dragView: false,
      hover: true
      },
      layout: {
      randomSeed: undefined,
      improvedLayout: true,
      hierarchical: {
      enabled: true,
      levelSeparation: 180,
      nodeSpacing: 180,
      edgeMinimization: true,
      parentCentralization: true,
      direction: 'UD', // UD, DU, LR, RL
      sortMethod: 'directed' // hubsize, directed
      }
      },
      physics: {
      enabled: false
      }
      }
      // initialize your network!
      this.network = new vis.Network(container, this.data, options);
      }


      When I add a node to my list of nodes for my network, this is my structure:



      addNode(node: any){
      try {
      this.data.nodes.add({
      id: node.id,
      color: node.color,
      title: node.title,
      label: node.label
      });
      this.network.fit();
      }
      catch (err) {}
      }


      The environment that I'm running my code from makes it difficult to provide an example of this issue live. Everything else in the network works just fine (label, id, color), just not the title when I hover over a node.



      EDIT:



      I copied this code from this example from vis.js where pop ups are working.



      // create an array with nodes
      var nodes = new vis.DataSet([
      {id: 1, label: 'Node 1', title: 'I have a popup!'},
      {id: 2, label: 'Node 2', title: 'I have a popup!'},
      {id: 3, label: 'Node 3', title: 'I have a popup!'},
      {id: 4, label: 'Node 4', title: 'I have a popup!'},
      {id: 5, label: 'Node 5', title: 'I have a popup!'}
      ]);

      // create an array with edges
      var edges = new vis.DataSet([
      {from: 1, to: 3},
      {from: 1, to: 2},
      {from: 2, to: 4},
      {from: 2, to: 5}
      ]);

      // create a network
      var container = document.getElementById('mynetwork');
      var data = {
      nodes: nodes,
      edges: edges
      };
      var options = {interaction:{hover:true}};
      this.network = new vis.Network(container, data, options);


      I tried using only this in my environment; however, the popups don't show up like in the example. I know my hovering event works because I included this code to print to console when I hover over a node:



      this.network.on("showPopup", function (params) {
      console.log("DO SOMETHING");
      })


      Is there some options setting that I'm missing here? Could there be some other issue as to why my hover popups don't show despite including the "title" property in my node objects?










      share|improve this question















      I am having an issue where despite including the 'title' property in my node objects, when I hover over a node, no pop up window with the contents of my title are displayed.



      Here are my options and how I set my network up.



      setUpNetwork(){
      let container = document.getElementById('mynetwork');
      //These options dictate the dynamic of the network
      let options = {
      nodes: {
      shape: 'box'
      },
      interaction: {
      dragNodes: false,
      dragView: false,
      hover: true
      },
      layout: {
      randomSeed: undefined,
      improvedLayout: true,
      hierarchical: {
      enabled: true,
      levelSeparation: 180,
      nodeSpacing: 180,
      edgeMinimization: true,
      parentCentralization: true,
      direction: 'UD', // UD, DU, LR, RL
      sortMethod: 'directed' // hubsize, directed
      }
      },
      physics: {
      enabled: false
      }
      }
      // initialize your network!
      this.network = new vis.Network(container, this.data, options);
      }


      When I add a node to my list of nodes for my network, this is my structure:



      addNode(node: any){
      try {
      this.data.nodes.add({
      id: node.id,
      color: node.color,
      title: node.title,
      label: node.label
      });
      this.network.fit();
      }
      catch (err) {}
      }


      The environment that I'm running my code from makes it difficult to provide an example of this issue live. Everything else in the network works just fine (label, id, color), just not the title when I hover over a node.



      EDIT:



      I copied this code from this example from vis.js where pop ups are working.



      // create an array with nodes
      var nodes = new vis.DataSet([
      {id: 1, label: 'Node 1', title: 'I have a popup!'},
      {id: 2, label: 'Node 2', title: 'I have a popup!'},
      {id: 3, label: 'Node 3', title: 'I have a popup!'},
      {id: 4, label: 'Node 4', title: 'I have a popup!'},
      {id: 5, label: 'Node 5', title: 'I have a popup!'}
      ]);

      // create an array with edges
      var edges = new vis.DataSet([
      {from: 1, to: 3},
      {from: 1, to: 2},
      {from: 2, to: 4},
      {from: 2, to: 5}
      ]);

      // create a network
      var container = document.getElementById('mynetwork');
      var data = {
      nodes: nodes,
      edges: edges
      };
      var options = {interaction:{hover:true}};
      this.network = new vis.Network(container, data, options);


      I tried using only this in my environment; however, the popups don't show up like in the example. I know my hovering event works because I included this code to print to console when I hover over a node:



      this.network.on("showPopup", function (params) {
      console.log("DO SOMETHING");
      })


      Is there some options setting that I'm missing here? Could there be some other issue as to why my hover popups don't show despite including the "title" property in my node objects?







      javascript node.js typescript vis.js vis.js-network






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 20:51









      YakovL

      2,770102337




      2,770102337










      asked Jul 21 '17 at 8:12









      Ebuka

      64




      64
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          I had the same issue. In my case it was a css issue. Make sure you import vis.min.css correcly. I had a typo in the link statement.






          share|improve this answer










          New contributor




          Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

























            up vote
            1
            down vote













            Nothing is showing because you are using event on("showPopup"). You have to use on("hoverNode"). So use



            network.on("hoverNode", function(){
            // functionality for popup to show on mouseover
            });


            network.on("blurNode", function(){
            // functionality for popup to hide on mouseout
            });


            For adding nodes its better to use



            nodes.add()





            share|improve this answer





















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45232460%2fwhy-dont-my-node-hover-popups-work-in-my-vis-js-network%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              I had the same issue. In my case it was a css issue. Make sure you import vis.min.css correcly. I had a typo in the link statement.






              share|improve this answer










              New contributor




              Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






















                up vote
                2
                down vote













                I had the same issue. In my case it was a css issue. Make sure you import vis.min.css correcly. I had a typo in the link statement.






                share|improve this answer










                New contributor




                Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.




















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  I had the same issue. In my case it was a css issue. Make sure you import vis.min.css correcly. I had a typo in the link statement.






                  share|improve this answer










                  New contributor




                  Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  I had the same issue. In my case it was a css issue. Make sure you import vis.min.css correcly. I had a typo in the link statement.







                  share|improve this answer










                  New contributor




                  Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer








                  edited Nov 12 at 17:45





















                  New contributor




                  Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Nov 12 at 17:30









                  Tom Dufresne

                  213




                  213




                  New contributor




                  Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Tom Dufresne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.
























                      up vote
                      1
                      down vote













                      Nothing is showing because you are using event on("showPopup"). You have to use on("hoverNode"). So use



                      network.on("hoverNode", function(){
                      // functionality for popup to show on mouseover
                      });


                      network.on("blurNode", function(){
                      // functionality for popup to hide on mouseout
                      });


                      For adding nodes its better to use



                      nodes.add()





                      share|improve this answer

























                        up vote
                        1
                        down vote













                        Nothing is showing because you are using event on("showPopup"). You have to use on("hoverNode"). So use



                        network.on("hoverNode", function(){
                        // functionality for popup to show on mouseover
                        });


                        network.on("blurNode", function(){
                        // functionality for popup to hide on mouseout
                        });


                        For adding nodes its better to use



                        nodes.add()





                        share|improve this answer























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          Nothing is showing because you are using event on("showPopup"). You have to use on("hoverNode"). So use



                          network.on("hoverNode", function(){
                          // functionality for popup to show on mouseover
                          });


                          network.on("blurNode", function(){
                          // functionality for popup to hide on mouseout
                          });


                          For adding nodes its better to use



                          nodes.add()





                          share|improve this answer












                          Nothing is showing because you are using event on("showPopup"). You have to use on("hoverNode"). So use



                          network.on("hoverNode", function(){
                          // functionality for popup to show on mouseover
                          });


                          network.on("blurNode", function(){
                          // functionality for popup to hide on mouseout
                          });


                          For adding nodes its better to use



                          nodes.add()






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 14 '17 at 14:14









                          Andrej Hucko

                          5010




                          5010






























                               

                              draft saved


                              draft discarded



















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45232460%2fwhy-dont-my-node-hover-popups-work-in-my-vis-js-network%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How to change which sound is reproduced for terminal bell?

                              Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                              Can I use Tabulator js library in my java Spring + Thymeleaf project?