From 937ac84538492571367c71a0513439133b8792a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 18 Aug 2014 21:47:56 +0200 Subject: [PATCH] Began work on per series style overrides, #425 --- src/app/directives/addGraphiteFunc.js | 2 +- src/app/directives/grafanaGraph.js | 4 ++- src/app/panels/graph/module.js | 48 +++++++++++++++++++++++++++ src/app/panels/graph/styleEditor.html | 39 ++++++++++++++++++++-- src/app/services/panelSrv.js | 2 +- 5 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/app/directives/addGraphiteFunc.js b/src/app/directives/addGraphiteFunc.js index ca5943da508..6898b838845 100644 --- a/src/app/directives/addGraphiteFunc.js +++ b/src/app/directives/addGraphiteFunc.js @@ -97,4 +97,4 @@ function (angular, app, _, $, gfunc) { }; }); } -}); \ No newline at end of file +}); diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index a91967b967b..f0ffd14dd67 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -156,9 +156,11 @@ function (angular, $, kbn, moment, _) { for (var i = 0; i < data.length; i++) { var _d = data[i].getFlotPairs(panel.nullPointMode, panel.y_formats); data[i].data = _d; + data[0].lines = { show: false }; + data[0].bars = { show: true }; } - if (panel.bars && data.length && data[0].info.timeStep) { + if (data.length && data[0].info.timeStep) { options.series.bars.barWidth = data[0].info.timeStep / 1.5; } diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 647e52c257e..d8a31f59312 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -180,6 +180,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) { aliasColors: {}, aliasYAxis: {}, + + seriesOverrides: [], }; _.defaults($scope.panel,_d); @@ -357,7 +359,53 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.render(); }; + $scope.addSeriesOverride = function() { + $scope.panel.seriesOverrides.push({}); + }; + panelSrv.init($scope); }); + angular + .module('grafana.directives') + .directive('seriesOverrideOption', function($compile) { + var template = + ''; + + return { + scope: true, + link: function($scope, elem, attrs) { + var $template = $(template); + elem.append($template); + var $link = $(elem).find('a'); + + $scope.options = $scope.$eval(attrs.options); + $scope.options.unshift(null); + + $scope.options = _.map($scope.options, function(option, index) { + return { + text: option === null ? '' : String(option), + value: option, + click: 'setValue(' + index + ')' + }; + }); + + $scope.setValue = function(index) { + var value = $scope.options[index].value; + if (value === null) { + $link.html(''); + } + else { + $link.html(value); + } + }; + + $compile(elem.contents())($scope); + } + }; + }); + }); diff --git a/src/app/panels/graph/styleEditor.html b/src/app/panels/graph/styleEditor.html index ec18121cba7..c1b68e25beb 100644 --- a/src/app/panels/graph/styleEditor.html +++ b/src/app/panels/graph/styleEditor.html @@ -1,5 +1,3 @@ - -
Chart Options
@@ -64,3 +62,40 @@
+ +
+
+
Series specific overrides
+ + + + + + + + + + + + + + + + + + + + +
Series alias/regexBarsLinesPointsFillWidthRadiusStaircaseStackY-axisZ-indexColor
+ + + + + + + +
+ + +
+
diff --git a/src/app/services/panelSrv.js b/src/app/services/panelSrv.js index 3c362818f2d..cae4f14ff98 100644 --- a/src/app/services/panelSrv.js +++ b/src/app/services/panelSrv.js @@ -104,7 +104,7 @@ function (angular, _) { // Post init phase $scope.fullscreen = false; - $scope.editor = { index: 1 }; + $scope.editor = { index: 3 }; if ($scope.panelMeta.fullEditorTabs) { $scope.editorTabs = _.pluck($scope.panelMeta.fullEditorTabs, 'title'); }