GraphDracula: How to detect onclick and onmouseover events?

1k views Asked by At

GraphDracula is a nice simple small graph visualization library based on RaphaelJS. However two very important things I would want it to detect are onmouseover (over a node) and onclick (over a node again).

e.g. In their most basic example, a mouseover on "cherry" node should give some extra details about cherry. Clicking it shall pop an alert box.

How can I do that ?

1

There are 1 answers

1
imsky On BEST ANSWER

You can do it by iterating through the nodes in the graph object and adding Raphael handlers on the shape object: http://jsfiddle.net/imsky/65Mpy/

var g = new Graph();
//Rest of code
for(var i in g.nodelist){
   g.nodelist[i].shape.mouseover(console.log)
   g.nodelist[i].shape.click(console.log)
}