GraphDracula: How to detect onclick and onmouseover events?
-
24-06-2021 - |
Question
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 ?
Solution
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)
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow