Commit caf1c7c9 authored by Cedric Le Roux's avatar Cedric Le Roux

Fixing Issue 686: Tooltip bug

parent b074bde4
...@@ -41,20 +41,15 @@ ...@@ -41,20 +41,15 @@
} }
}); });
function showTooltip(x, y, contents) { $("<div id='tooltip'></div>").css({
$("<div id='tooltip'>" + contents + "</div>").css({
position: "absolute", position: "absolute",
display: "none", display: "none",
top: y + 5,
left: x + 5,
border: "1px solid #fdd", border: "1px solid #fdd",
padding: "2px", padding: "2px",
"background-color": "#fee", "background-color": "#fee",
opacity: 0.80 opacity: 0.80
}).appendTo("body").fadeIn(200); }).appendTo("body");
}
var previousPoint = null;
$("#placeholder").bind("plothover", function (event, pos, item) { $("#placeholder").bind("plothover", function (event, pos, item) {
if ($("#enablePosition:checked").length > 0) { if ($("#enablePosition:checked").length > 0) {
...@@ -64,20 +59,14 @@ ...@@ -64,20 +59,14 @@
if ($("#enableTooltip:checked").length > 0) { if ($("#enableTooltip:checked").length > 0) {
if (item) { if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2), var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2); y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, $("#tooltip").html(item.series.label + " of " + x + " = " + y)
item.series.label + " of " + x + " = " + y); .css({top: item.pageY+5, left: item.pageX+5})
} .fadeIn(200);
} else { } else {
$("#tooltip").remove(); $("#tooltip").hide();
previousPoint = null;
} }
} }
}); });
...@@ -97,7 +86,6 @@ ...@@ -97,7 +86,6 @@
</script> </script>
</head> </head>
<body> <body>
<div id="header"> <div id="header">
<h2>Interactivity</h2> <h2>Interactivity</h2>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment