usernamegoeshere
usernamegoeshere

Reputation: 31

Javascript InfoVis Spacetree - Dynamically hide/show Tooltips

I've been googling this and can't seem to find an answer. I will also ask this in the JavaScript InfoVis Toolkit Google Group.

I was wondering if it's possible to dynamically hide/show tooltips using InfoVis spacetree. Currently they are turned on and I have set up the tips like this:

Tips: {
        enable: true,
        type: 'HTML',
        offsetX: 10,
        offsetY: 10,
        onShow: function (tip, node)
        {
            tip.innerHTML = getToolTip(node);
        }
    },

but I can't seem to find any references for how I might turn them off later. For example, I want the user to be able to check a box to hide/show Tooltips and then display them accordingly. I tried st.tips.hide() (st is the name of my spacetree) but it doesn't do anything. If I do alert(st.tips) I get an object but I don't know what functions are available on the object.

Any help would be much appreciated! Thanks!

Upvotes: 3

Views: 1758

Answers (1)

Oliver
Oliver

Reputation: 71

I'm using ForceDirected and had a similar problem. I wanted to keep the tooltip displayed for a certain period of time after the user leaves the node with the cursor...

Calling

graph.tips.hide(false)

works for me (did you ever try passing an argument to hide?). I can't tell you whether to pass true or false, they both work for me...

Overall you could try something like:

Tips: {  
      enable: true,
      type: 'HTMl',
      onShow: function(tip, node, isLeaf, domElement) {
          //Check if checkbox is checked
          var checked = $('input[type=checkbox]').is(':checked');

          if (checked == true){
            tip.innerHTML =  getToolTip(node);
          } else {
            graph.tips.hide(true);
          };
      } 

In any case this is just an idea and I don't have the time to test it (pseudocode?..)

Hope this helped!

Cheers

Upvotes: 4

Related Questions