|
@@ -2,7 +2,7 @@ define([
|
|
|
'jquery',
|
|
'jquery',
|
|
|
'lodash'
|
|
'lodash'
|
|
|
],
|
|
],
|
|
|
-function ($, _) {
|
|
|
|
|
|
|
+function ($) {
|
|
|
'use strict';
|
|
'use strict';
|
|
|
|
|
|
|
|
function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
|
|
function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
|
|
@@ -21,7 +21,8 @@ function ($, _) {
|
|
|
var initial = last*ps;
|
|
var initial = last*ps;
|
|
|
var len = series.datapoints.points.length;
|
|
var len = series.datapoints.points.length;
|
|
|
for (var j = initial; j < len; j += ps) {
|
|
for (var j = initial; j < len; j += ps) {
|
|
|
- if (series.datapoints.points[j] > posX) {
|
|
|
|
|
|
|
+ if ((series.datapoints.points[initial] != null && series.datapoints.points[j] == null && ! series.lines.steps)
|
|
|
|
|
+ || series.datapoints.points[j] > posX) {
|
|
|
return Math.max(j - ps, 0)/ps;
|
|
return Math.max(j - ps, 0)/ps;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -51,6 +52,8 @@ function ($, _) {
|
|
|
//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
|
|
|
|
|
|
|
|
|
|
+ var minDistance, minTime;
|
|
|
|
|
+
|
|
|
for (i = 0; i < seriesList.length; i++) {
|
|
for (i = 0; i < seriesList.length; i++) {
|
|
|
series = seriesList[i];
|
|
series = seriesList[i];
|
|
|
|
|
|
|
@@ -65,9 +68,16 @@ function ($, _) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
hoverIndex = this.findHoverIndexFromData(pos.x, series);
|
|
hoverIndex = this.findHoverIndexFromData(pos.x, series);
|
|
|
- hoverDistance = Math.abs(pos.x - series.data[hoverIndex][0]);
|
|
|
|
|
|
|
+ hoverDistance = pos.x - series.data[hoverIndex][0];
|
|
|
pointTime = 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 (series.stack) {
|
|
|
if (panel.tooltip.value_type === 'individual') {
|
|
if (panel.tooltip.value_type === 'individual') {
|
|
|
value = series.data[hoverIndex][1];
|
|
value = series.data[hoverIndex][1];
|
|
@@ -107,7 +117,7 @@ function ($, _) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Find point which closer to pointer
|
|
// Find point which closer to pointer
|
|
|
- results.time = _.min(results, 'distance').time;
|
|
|
|
|
|
|
+ results.time = minTime;
|
|
|
|
|
|
|
|
return results;
|
|
return results;
|
|
|
};
|
|
};
|
|
@@ -153,6 +163,8 @@ function ($, _) {
|
|
|
|
|
|
|
|
seriesHtml = '';
|
|
seriesHtml = '';
|
|
|
|
|
|
|
|
|
|
+ absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat);
|
|
|
|
|
+
|
|
|
// Dynamically reorder the hovercard for the current time point if the
|
|
// Dynamically reorder the hovercard for the current time point if the
|
|
|
// option is enabled, sort by yaxis by default.
|
|
// option is enabled, sort by yaxis by default.
|
|
|
if (panel.tooltip.sort === 2) {
|
|
if (panel.tooltip.sort === 2) {
|
|
@@ -169,8 +181,6 @@ function ($, _) {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var distance, time;
|
|
|
|
|
-
|
|
|
|
|
for (i = 0; i < seriesHoverInfo.length; i++) {
|
|
for (i = 0; i < seriesHoverInfo.length; i++) {
|
|
|
hoverInfo = seriesHoverInfo[i];
|
|
hoverInfo = seriesHoverInfo[i];
|
|
|
|
|
|
|
@@ -178,11 +188,6 @@ function ($, _) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (! distance || hoverInfo.distance < distance) {
|
|
|
|
|
- distance = hoverInfo.distance;
|
|
|
|
|
- time = hoverInfo.time;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
var highlightClass = '';
|
|
var highlightClass = '';
|
|
|
if (item && i === item.seriesIndex) {
|
|
if (item && i === item.seriesIndex) {
|
|
|
highlightClass = 'graph-tooltip-list-item--highlight';
|
|
highlightClass = 'graph-tooltip-list-item--highlight';
|
|
@@ -198,7 +203,6 @@ function ($, _) {
|
|
|
plot.highlight(hoverInfo.index, hoverInfo.hoverIndex);
|
|
plot.highlight(hoverInfo.index, hoverInfo.hoverIndex);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- absoluteTime = dashboard.formatDate(time, tooltipFormat);
|
|
|
|
|
self.showTooltip(absoluteTime, seriesHtml, pos);
|
|
self.showTooltip(absoluteTime, seriesHtml, pos);
|
|
|
}
|
|
}
|
|
|
// single series tooltip
|
|
// single series tooltip
|