From caccacf52b46b927abbf046070a7519dcb3c5341 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Thu, 13 Aug 2015 13:16:51 +0900 Subject: [PATCH] don't calculate cumulative value if series overrides stack to false --- public/app/panels/graph/graph.tooltip.js | 2 ++ public/test/specs/graph-tooltip-specs.js | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/public/app/panels/graph/graph.tooltip.js b/public/app/panels/graph/graph.tooltip.js index 33c29e4e14a..9f9b5959331 100644 --- a/public/app/panels/graph/graph.tooltip.js +++ b/public/app/panels/graph/graph.tooltip.js @@ -58,6 +58,8 @@ function ($) { if (scope.panel.stack) { if (scope.panel.tooltip.value_type === 'individual') { value = series.data[hoverIndex][1]; + } else if (!series.stack) { + value = series.data[hoverIndex][1]; } else { last_value += series.data[hoverIndex][1]; value = last_value; diff --git a/public/test/specs/graph-tooltip-specs.js b/public/test/specs/graph-tooltip-specs.js index da02b9f2e0a..f58759517da 100644 --- a/public/test/specs/graph-tooltip-specs.js +++ b/public/test/specs/graph-tooltip-specs.js @@ -73,8 +73,8 @@ define([ describeSharedTooltip("steppedLine false, stack true, individual false", function(ctx) { ctx.setup(function() { ctx.data = [ - { data: [[10, 15], [12, 20]], }, - { data: [[10, 2], [12, 3]], } + { data: [[10, 15], [12, 20]], stack: true }, + { data: [[10, 2], [12, 3]], stack: true } ]; ctx.scope.panel.stack = true; ctx.pos = { x: 11 }; @@ -86,6 +86,22 @@ define([ }); + describeSharedTooltip("steppedLine false, stack true, individual false, series stack false", function(ctx) { + ctx.setup(function() { + ctx.data = [ + { data: [[10, 15], [12, 20]], stack: true }, + { data: [[10, 2], [12, 3]], stack: false } + ]; + ctx.scope.panel.stack = true; + ctx.pos = { x: 11 }; + }); + + it('should not show stacked value', function() { + expect(ctx.results[1].value).to.be(2); + }); + + }); + describeSharedTooltip("steppedLine false, stack true, individual true", function(ctx) { ctx.setup(function() { ctx.data = [