Commit 34804bda by Torkel Ödegaard

Merge branch 'issue-3063' of https://github.com/alexanderzobnin/grafana into…

Merge branch 'issue-3063' of https://github.com/alexanderzobnin/grafana into alexanderzobnin-issue-3063
parents d49f0569 2c283ddd
define([ define([
'jquery', 'jquery',
'lodash'
], ],
function ($) { function ($, _) {
'use strict'; 'use strict';
function GraphTooltip(elem, dashboard, scope, getSeriesFn) { function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
...@@ -40,8 +41,9 @@ function ($) { ...@@ -40,8 +41,9 @@ function ($) {
}; };
this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) { this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) {
var value, i, series, hoverIndex; var value, i, series, hoverIndex, hoverDistance;
var results = []; var results = [];
var seriesTimes = new Array(seriesList.length);
//now we know the current X (j) position for X and Y values //now we know the current X (j) position for X and Y values
var last_value = 0; //needed for stacked values var last_value = 0; //needed for stacked values
...@@ -60,7 +62,13 @@ function ($) { ...@@ -60,7 +62,13 @@ function ($) {
} }
hoverIndex = this.findHoverIndexFromData(pos.x, series); hoverIndex = this.findHoverIndexFromData(pos.x, series);
results.time = series.data[hoverIndex][0];
// Store distance for each highlighted point
hoverDistance = Math.abs(pos.x - series.data[hoverIndex][0]);
seriesTimes[i] = {
time: series.data[hoverIndex][0],
distance: hoverDistance
};
if (series.stack) { if (series.stack) {
if (panel.tooltip.value_type === 'individual') { if (panel.tooltip.value_type === 'individual') {
...@@ -87,6 +95,9 @@ function ($) { ...@@ -87,6 +95,9 @@ function ($) {
} }
} }
// Find point which closer to pointer
results.time = _.min(seriesTimes, 'distance').time;
return results; return results;
}; };
......
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