mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Graph: fixed issue with shared tooltip when one or more series is hidden, Fixes #1094
This commit is contained in:
@@ -38,18 +38,26 @@ function ($) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) {
|
this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) {
|
||||||
var value, i, series, hoverIndex;
|
var value, i, series, hoverIndex, seriesTmp;
|
||||||
var results = [];
|
var results = [];
|
||||||
|
|
||||||
var pointCount = seriesList[0].data.length;
|
var pointCount;
|
||||||
for (i = 1; i < seriesList.length; i++) {
|
for (i = 0; i < seriesList.length; i++) {
|
||||||
if (seriesList[i].data.length !== pointCount) {
|
seriesTmp = seriesList[i];
|
||||||
|
if (!seriesTmp.data.length) { continue; }
|
||||||
|
|
||||||
|
if (!pointCount) {
|
||||||
|
series = seriesTmp;
|
||||||
|
pointCount = series.data.length;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seriesTmp.data.length !== pointCount) {
|
||||||
results.pointCountMismatch = true;
|
results.pointCountMismatch = true;
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
series = seriesList[0];
|
|
||||||
hoverIndex = this.findHoverIndexFromData(pos.x, series);
|
hoverIndex = this.findHoverIndexFromData(pos.x, series);
|
||||||
var lasthoverIndex = 0;
|
var lasthoverIndex = 0;
|
||||||
if(!scope.panel.steppedLine) {
|
if(!scope.panel.steppedLine) {
|
||||||
@@ -62,6 +70,7 @@ function ($) {
|
|||||||
|
|
||||||
for (i = 0; i < seriesList.length; i++) {
|
for (i = 0; i < seriesList.length; i++) {
|
||||||
series = seriesList[i];
|
series = seriesList[i];
|
||||||
|
if (!series.data.length) { continue; }
|
||||||
|
|
||||||
if (scope.panel.stack) {
|
if (scope.panel.stack) {
|
||||||
if (scope.panel.tooltip.value_type === 'individual') {
|
if (scope.panel.tooltip.value_type === 'individual') {
|
||||||
|
|||||||
@@ -59,6 +59,34 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describeSharedTooltip("point count missmatch", function(ctx) {
|
||||||
|
ctx.setup(function() {
|
||||||
|
ctx.data = [
|
||||||
|
{ data: [[10, 15], [12, 20]], },
|
||||||
|
{ data: [[10, 2]] }
|
||||||
|
];
|
||||||
|
ctx.pos = { x: 11 };
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set pointCountMismatch to true', function() {
|
||||||
|
expect(ctx.results.pointCountMismatch).to.be(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describeSharedTooltip("one series is hidden", function(ctx) {
|
||||||
|
ctx.setup(function() {
|
||||||
|
ctx.data = [
|
||||||
|
{ data: [[10, 15], [12, 20]], },
|
||||||
|
{ data: [] }
|
||||||
|
];
|
||||||
|
ctx.pos = { x: 11 };
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set pointCountMismatch to false', function() {
|
||||||
|
expect(ctx.results.pointCountMismatch).to.be(undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describeSharedTooltip("steppedLine false, stack true, individual false", function(ctx) {
|
describeSharedTooltip("steppedLine false, stack true, individual false", function(ctx) {
|
||||||
ctx.setup(function() {
|
ctx.setup(function() {
|
||||||
ctx.data = [
|
ctx.data = [
|
||||||
|
|||||||
Reference in New Issue
Block a user