From d43f8566e84de3f3b7aa776dba3173a1246d438b Mon Sep 17 00:00:00 2001 From: Carl Sutherland Date: Thu, 21 Mar 2013 22:13:08 -0400 Subject: [PATCH] Hide tracker if content null or undefined. For #207. If the user returns an empty string, I won't decide not to show it. --- js/plugins/hit.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/plugins/hit.js b/js/plugins/hit.js index 804bd7ea..696af05a 100644 --- a/js/plugins/hit.js +++ b/js/plugins/hit.js @@ -296,7 +296,7 @@ Flotr.addPlugin('hit', { container = options.mouse.container, oTop = 0, oLeft = 0, - offset, size; + offset, size, content; // Create if (!mouseTrack) { @@ -309,7 +309,7 @@ Flotr.addPlugin('hit', { if (!decimals || decimals < 0) decimals = 0; if (x && x.toFixed) x = x.toFixed(decimals); if (y && y.toFixed) y = y.toFixed(decimals); - mouseTrack.innerHTML = n.mouse.trackFormatter({ + content = n.mouse.trackFormatter({ x: x, y: y, series: n.series, @@ -317,7 +317,13 @@ Flotr.addPlugin('hit', { nearest: n, fraction: n.fraction }); - D.show(mouseTrack); + if (_.isNull(content) || _.isUndefined(content)) { + D.hide(mouseTrack); + return; + } else { + mouseTrack.innerHTML = content; + D.show(mouseTrack); + } // Positioning size = D.size(mouseTrack);