From e71114f4fb09f690ccd3910c77fa2589999cfa14 Mon Sep 17 00:00:00 2001 From: benrubson Date: Sat, 19 Nov 2016 09:12:10 +0100 Subject: [PATCH] Come back to #6287 for graph_tooltip.js as it is an only one loop solution --- public/app/plugins/panel/graph/graph_tooltip.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/panel/graph/graph_tooltip.js b/public/app/plugins/panel/graph/graph_tooltip.js index 09b61493e3f..e3c5a1edf85 100644 --- a/public/app/plugins/panel/graph/graph_tooltip.js +++ b/public/app/plugins/panel/graph/graph_tooltip.js @@ -21,15 +21,14 @@ function ($) { var initial = last*ps; var len = series.datapoints.points.length; for (var j = initial; j < len; j += ps) { - if (series.datapoints.points[j] > posX) { - break; + // Special case of a non stepped line, highlight the very last point just before a null point + if ((!series.lines.steps && series.datapoints.points[initial] != null && series.datapoints.points[j] == null) + //normal case + || series.datapoints.points[j] > posX) { + return Math.max(j - ps, 0)/ps; } } - // Special case of a non stepped line, highlight the very last point just before a null point - while(!series.lines.steps && series.datapoints.points[initial] != null && j>0 && series.datapoints.points[j-ps] == null) { - j-=ps; - } - return Math.max(j - ps, 0)/ps; + return j/ps - 1; }; this.findHoverIndexFromData = function(posX, series) {