mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add time back to result array
This commit is contained in:
@@ -48,6 +48,8 @@ function ($) {
|
||||
//now we know the current X (j) position for X and Y values
|
||||
var last_value = 0; //needed for stacked values
|
||||
|
||||
var minDistance, minTime;
|
||||
|
||||
for (i = 0; i < seriesList.length; i++) {
|
||||
series = seriesList[i];
|
||||
|
||||
@@ -65,6 +67,13 @@ function ($) {
|
||||
hoverDistance = pos.x - series.data[hoverIndex][0];
|
||||
pointTime = series.data[hoverIndex][0];
|
||||
|
||||
if (! minDistance
|
||||
|| (hoverDistance >=0 && (hoverDistance < minDistance || minDistance < 0))
|
||||
|| (hoverDistance < 0 && hoverDistance > minDistance)) {
|
||||
minDistance = hoverDistance;
|
||||
minTime = pointTime;
|
||||
}
|
||||
|
||||
if (series.stack) {
|
||||
if (panel.tooltip.value_type === 'individual') {
|
||||
value = series.data[hoverIndex][1];
|
||||
@@ -103,6 +112,9 @@ function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
// Find point which closer to pointer
|
||||
results.time = minTime;
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
@@ -147,6 +159,8 @@ function ($) {
|
||||
|
||||
seriesHtml = '';
|
||||
|
||||
absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat);
|
||||
|
||||
// Dynamically reorder the hovercard for the current time point if the
|
||||
// option is enabled, sort by yaxis by default.
|
||||
if (panel.tooltip.sort === 2) {
|
||||
@@ -163,8 +177,6 @@ function ($) {
|
||||
});
|
||||
}
|
||||
|
||||
var distance, time;
|
||||
|
||||
for (i = 0; i < seriesHoverInfo.length; i++) {
|
||||
hoverInfo = seriesHoverInfo[i];
|
||||
|
||||
@@ -172,13 +184,6 @@ function ($) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! distance
|
||||
|| (hoverInfo.distance >=0 && (hoverInfo.distance < distance || distance < 0))
|
||||
|| (hoverInfo.distance < 0 && hoverInfo.distance > distance)) {
|
||||
distance = hoverInfo.distance;
|
||||
time = hoverInfo.time;
|
||||
}
|
||||
|
||||
var highlightClass = '';
|
||||
if (item && i === item.seriesIndex) {
|
||||
highlightClass = 'graph-tooltip-list-item--highlight';
|
||||
@@ -194,7 +199,6 @@ function ($) {
|
||||
plot.highlight(hoverInfo.index, hoverInfo.hoverIndex);
|
||||
}
|
||||
|
||||
absoluteTime = dashboard.formatDate(time, tooltipFormat);
|
||||
self.showTooltip(absoluteTime, seriesHtml, pos);
|
||||
}
|
||||
// single series tooltip
|
||||
|
||||
Reference in New Issue
Block a user