Graph: fixed issue with shared tooltip when one or more series is hidden, Fixes #1094

This commit is contained in:
Torkel Ödegaard 2014-11-19 16:01:04 +01:00
parent dd398f73c2
commit 91d6641326
2 changed files with 42 additions and 5 deletions

View File

@ -38,18 +38,26 @@ function ($) {
};
this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) {
var value, i, series, hoverIndex;
var value, i, series, hoverIndex, seriesTmp;
var results = [];
var pointCount = seriesList[0].data.length;
for (i = 1; i < seriesList.length; i++) {
if (seriesList[i].data.length !== pointCount) {
var pointCount;
for (i = 0; i < seriesList.length; i++) {
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;
return results;
}
}
series = seriesList[0];
hoverIndex = this.findHoverIndexFromData(pos.x, series);
var lasthoverIndex = 0;
if(!scope.panel.steppedLine) {
@ -62,6 +70,7 @@ function ($) {
for (i = 0; i < seriesList.length; i++) {
series = seriesList[i];
if (!series.data.length) { continue; }
if (scope.panel.stack) {
if (scope.panel.tooltip.value_type === 'individual') {

View File

@ -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) {
ctx.setup(function() {
ctx.data = [