From caf1c7c9a5305e93f6889540cfdf4039eb485913 Mon Sep 17 00:00:00 2001 From: Cedric Le Roux Date: Sat, 15 Jun 2013 01:09:18 -0700 Subject: [PATCH] Fixing Issue 686: Tooltip bug --- examples/interacting/index.html | 38 +++++++++++---------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/examples/interacting/index.html b/examples/interacting/index.html index 15b2437..982aa2f 100644 --- a/examples/interacting/index.html +++ b/examples/interacting/index.html @@ -41,20 +41,15 @@ } }); - function showTooltip(x, y, contents) { - $("
" + contents + "
").css({ - position: "absolute", - display: "none", - top: y + 5, - left: x + 5, - border: "1px solid #fdd", - padding: "2px", - "background-color": "#fee", - opacity: 0.80 - }).appendTo("body").fadeIn(200); - } + $("
").css({ + position: "absolute", + display: "none", + border: "1px solid #fdd", + padding: "2px", + "background-color": "#fee", + opacity: 0.80 + }).appendTo("body"); - var previousPoint = null; $("#placeholder").bind("plothover", function (event, pos, item) { if ($("#enablePosition:checked").length > 0) { @@ -64,20 +59,14 @@ if ($("#enableTooltip:checked").length > 0) { 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); - showTooltip(item.pageX, item.pageY, - item.series.label + " of " + x + " = " + y); - } + $("#tooltip").html(item.series.label + " of " + x + " = " + y) + .css({top: item.pageY+5, left: item.pageX+5}) + .fadeIn(200); } else { - $("#tooltip").remove(); - previousPoint = null; + $("#tooltip").hide(); } } }); @@ -97,7 +86,6 @@ -