I'm doing a bit of a pedagogical exercise, converting XML to SVG with XSLT, Javascript and Raphael. I'm sure it's the hard way...but it's educational.
The problem I've run into is creating tooltips. So far, I've found three ways to do this:
.attr({title: "blah"{)
on an object. This works, but it's not supported by Raphael officially, and the content I want to put in the tooltip might be somewhat long, which is a problem when people's OS times out the tooltip before people have finished reading it.So, what I'd like to know is, what's an easy and reliable way to add tooltips to Raphael objects such that they popup when people mouseover the object, and disappear when they mouseout (but not before)?
One way to do this is to use a div tag on top of the Raphael paper. Then use Jquery mousevents along with fadeIn() and fadeOut(). I created an example on jsFiddle. Have a look
If you use [title] attributes, it will wrap the elements with links making it easy to use tooltip plugins like qtip.
var R = Raphael('canvas', 100, 100); R.path(path).attr({ title: 'Fancy tooltip' }); $('#canvas a').qtip();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With