0

I am trying to add Tipsy hover-over popups to my simple force-directed graph of 3 nodes.

However, adding the Tipsy javascript seems to crash my javascript: http://goo.gl/BeYls

Chrome Web Developer Console notes:

Uncaught TypeError: Object [object SVGCircleElement],[object SVGCircleElement],[object SVGCircleElement] has no method 'tipsy'

I am sure that the rest of the application without the Tipsy code works (since taking out lines 78-85 fixes the app), and I have included the javascript files.

Specifically, here is the code I wrote to add Tipsy popups to each node in the DOM.

  node.tipsy({  
    gravity: 'w', 
    html: true, 
    title: function() {
    var d = this.__data__, n = d.name;
        return 'Hi there! My name is <b>' + n + '</b>'; 
    }
  });

Why is it breaking? Is node not a DOM element?

ZachB
  • 13,051
  • 4
  • 61
  • 89
dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206
  • 1
    Isn't tipsy a jQuery plugin? In which case you would have to wrap the node in a jQuery function call: $(node) – aefxx Apr 14 '12 at 23:13

1 Answers1

3

Tipsy is a jquery plugin. You need to apply it on jquery selectors, not d3 selectors. Since your circles have the css class 'node', this should work:

$(".node").tipsy({ ... });
Lars Grammel
  • 1,999
  • 16
  • 21