From 062fe72030ebf466cec4d06cbb1d131505f50666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 19 Aug 2014 17:24:37 +0200 Subject: [PATCH] More options can now be set on pre series basis, this is awesome! --- src/app/directives/grafanaGraph.js | 5 +++ src/app/panels/graph/seriesOverridesCtrl.js | 5 ++- src/test/specs/grafanaGraph-specs.js | 36 +++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index e4f527bb2f3..f624c90494d 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -187,6 +187,7 @@ function (angular, $, kbn, moment, _) { series.lines = {}; series.points = {}; series.bars = {}; + delete series.stack; for (var i = 0; i < scope.panel.seriesOverrides.length; i++) { var override = scope.panel.seriesOverrides[i]; @@ -197,6 +198,10 @@ function (angular, $, kbn, moment, _) { if (override.points !== void 0) { series.points.show = override.points; } if (override.bars !== void 0) { series.bars.show = override.bars; } if (override.fill !== void 0) { series.lines.fill = translateFillOption(override.fill); } + if (override.stack !== void 0) { series.stack = override.stack; } + if (override.linewidth !== void 0) { series.lines.lineWidth = override.linewidth; } + if (override.pointradius !== void 0) { series.points.radius = override.pointradius; } + if (override.steppedLine !== void 0) { series.lines.steps = override.steppedLine; } } } diff --git a/src/app/panels/graph/seriesOverridesCtrl.js b/src/app/panels/graph/seriesOverridesCtrl.js index 9f42f3ef75d..d2f083b2699 100644 --- a/src/app/panels/graph/seriesOverridesCtrl.js +++ b/src/app/panels/graph/seriesOverridesCtrl.js @@ -59,9 +59,12 @@ define([ $scope.addOverrideOption('Bars', 'bars', [true, false]); $scope.addOverrideOption('Lines', 'lines', [true, false]); - $scope.addOverrideOption('Points', 'points', [true, false]); $scope.addOverrideOption('Line fill', 'fill', [0,1,2,3,4,5,6,7,8,9,10]); $scope.addOverrideOption('Line width', 'linewidth', [0,1,2,3,4,5,6,7,8,9,10]); + $scope.addOverrideOption('Staircase line', 'steppedLine', [true, false]); + $scope.addOverrideOption('Points', 'points', [true, false]); + $scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]); + $scope.addOverrideOption('Stack', 'stack', [true, false]); $scope.updateCurrentOverrides(); }); diff --git a/src/test/specs/grafanaGraph-specs.js b/src/test/specs/grafanaGraph-specs.js index b070c03ec44..162ad278ce3 100644 --- a/src/test/specs/grafanaGraph-specs.js +++ b/src/test/specs/grafanaGraph-specs.js @@ -109,6 +109,42 @@ define([ }); }); + graphScenario('series option overrides, linewidth, stack', function(ctx) { + ctx.setup(function(scope, data) { + scope.panel.lines = true; + scope.panel.stack = true; + scope.panel.linewidth = 2; + scope.panel.seriesOverrides = [ + { alias: 'test', linewidth: 5, stack: false } + ]; + + data[1].info.alias = 'test'; + }); + + it('should match second series and disable stack, and set lineWidth', function() { + expect(ctx.plotOptions.series.stack).to.be(true); + expect(ctx.plotData[1].stack).to.be(false); + expect(ctx.plotData[1].lines.lineWidth).to.be(5); + }); + }); + + graphScenario('series option overrides, pointradius, steppedLine', function(ctx) { + ctx.setup(function(scope, data) { + scope.panel.seriesOverrides = [ + { alias: 'test', pointradius: 5, steppedLine: true } + ]; + + data[1].info.alias = 'test'; + }); + + it('should match second series and set pointradius, and set steppedLine', function() { + expect(ctx.plotData[1].points.radius).to.be(5); + expect(ctx.plotData[1].lines.steps).to.be(true); + }); + }); + + + }); });