mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixed shared tooltip time calculation. Fixes #3063.
This commit is contained in:
parent
84d7305d37
commit
2c283ddd77
@ -1,7 +1,8 @@
|
|||||||
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 ($) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
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 ($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 ($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find point which closer to pointer
|
||||||
|
results.time = _.min(seriesTimes, 'distance').time;
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user