From ce2ae31950989fd6bcfeec25d00cc59cac8ec2a3 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Fri, 17 Jul 2015 12:23:30 +0200 Subject: [PATCH 1/2] Use percent-formatter for stack+percentage graph --- public/app/plugins/panels/graph/graph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/panels/graph/graph.js b/public/app/plugins/panels/graph/graph.js index 31c4e541f40..39c1c6707c1 100755 --- a/public/app/plugins/panels/graph/graph.js +++ b/public/app/plugins/panels/graph/graph.js @@ -380,11 +380,11 @@ function (angular, $, moment, _, kbn, GraphTooltip) { options.yaxes.push(secondY); applyLogScale(options.yaxes[1], data); - configureAxisMode(options.yaxes[1], scope.panel.y_formats[1]); + configureAxisMode(options.yaxes[1], scope.panel.percentage && scope.panel.stack ? "percent" : scope.panel.y_formats[1]); } applyLogScale(options.yaxes[0], data); - configureAxisMode(options.yaxes[0], scope.panel.y_formats[0]); + configureAxisMode(options.yaxes[0], scope.panel.percentage && scope.panel.stack ? "percent" : scope.panel.y_formats[0]); } function applyLogScale(axis, data) { From b99ea80b581a582908eae4612a837b6449838069 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Tue, 15 Dec 2015 17:28:49 +0100 Subject: [PATCH 2/2] test(graph): validates that percentage is shown when using stack and percentage fixes #2379 --- public/test/specs/graph-specs.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/test/specs/graph-specs.js b/public/test/specs/graph-specs.js index 60637296564..29fdeeb825e 100644 --- a/public/test/specs/graph-specs.js +++ b/public/test/specs/graph-specs.js @@ -215,6 +215,17 @@ define([ }); }); + graphScenario('when stack and percent', function(ctx) { + ctx.setup(function(scope) { + scope.panel.percentage = true; + scope.panel.stack = true; + }); + + it('should show percentage', function() { + var axis = ctx.plotOptions.yaxes[0]; + expect(axis.tickFormatter(100, axis)).to.be("100%"); + }); + }); }); });