Created
January 5, 2011 19:19
-
-
Save jonrohan/766844 to your computer and use it in GitHub Desktop.
Showing the Tooltip Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Circle gets the sqaure. <circle> is an SVG dom element and has hover events. | |
// setting up the circle hover event using JQuery | |
$("circle").hover(function() { | |
// get the tooltip, and put some stuff in it | |
$(".chart-wrapper .tooltip-inner .stuff") | |
// because the circle is an element, I can add data to it | |
.text("Queries/Day: " + $(this).attr("calls") + " (" + $(this).attr("date") + ")"); | |
// position, and show the tooltip | |
$(".chart-wrapper .tooltip") | |
.css({ | |
"display" : "block", | |
"opacity" : 1, | |
"top" : parseInt($(this).attr("cy").baseVal.value + 5)+"px", | |
"left" : parseInt($(this).attr("cx").baseVal.value + 10)+"px" | |
}); | |
}, function() { | |
// hover out, so just hide it | |
$(".chart-wrapper .tooltip").css({"opacity":0,"display":"none"}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment