From 5c80f03eae1ba47abd91499913370a6c4852e165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 15 Oct 2014 18:16:04 -0400 Subject: [PATCH] StatsPanel: small progress on stats panel --- src/app/panels/stats/module.js | 40 +++++++++++++++++---------- src/app/panels/stats/statsEditor.html | 21 +++++++++++++- src/css/less/stats-panel.less | 4 +++ 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/app/panels/stats/module.js b/src/app/panels/stats/module.js index 471d6db4f41..4847c27e102 100644 --- a/src/app/panels/stats/module.js +++ b/src/app/panels/stats/module.js @@ -38,6 +38,10 @@ function (angular, app, _, TimeSeries, kbn) { var _d = { targets: [{}], cacheTimeout: null, + format: 'none', + avg: true, + stats: true, + table: true, }; _.defaults($scope.panel, _d); @@ -80,19 +84,7 @@ function (angular, app, _, TimeSeries, kbn) { $scope.dataHandler = function(results) { $scope.panelMeta.loading = false; - var data= {}; - data.series = _.map(results.data, $scope.seriesHandler); - data.stats = []; - - if (data.series.length > 0) { - var stat = {}; - var firstSeries = data.series[0]; - stat.value = $scope.formatValue(firstSeries.stats.avg); - stat.func = 'avg'; - data.stats.push(stat); - } - - $scope.data = data; + $scope.series = _.map(results.data, $scope.seriesHandler); $scope.render(); }; @@ -119,6 +111,22 @@ function (angular, app, _, TimeSeries, kbn) { }; $scope.render = function() { + var data = { + series: $scope.series, + stats: [] + }; + + var main = data.series[0]; + + if ($scope.panel.avg) { + data.stats.push({ value: $scope.formatValue(main.stats.avg), func: 'avg' }); + } + + if ($scope.panel.total) { + data.stats.push({ value: $scope.formatValue(main.stats.total), func: 'total' }); + } + + $scope.data = data; $scope.$emit('render'); }; @@ -149,8 +157,10 @@ function (angular, app, _, TimeSeries, kbn) { if (scope.panel.stats) { body += '
'; - body += '' + data.stats[0].value + ''; - body += ' (' + data.stats[0].func + ')'; + for (i = 0; i < scope.data.stats.length; i++) { + body += '' + data.stats[i].value + ''; + body += ' (' + data.stats[i].func + ')'; + } body += '
'; } diff --git a/src/app/panels/stats/statsEditor.html b/src/app/panels/stats/statsEditor.html index cb473e03122..297738ef218 100644 --- a/src/app/panels/stats/statsEditor.html +++ b/src/app/panels/stats/statsEditor.html @@ -2,8 +2,23 @@
Main options
- +
+
+
Big values
+ + + + + +
+
+
Formats
+
+ + +
+
@@ -12,6 +27,10 @@
    +
  • + +
  • +
  • {{series.info.alias}}
  • diff --git a/src/css/less/stats-panel.less b/src/css/less/stats-panel.less index 2a9276d42fe..ad1ad017628 100644 --- a/src/css/less/stats-panel.less +++ b/src/css/less/stats-panel.less @@ -8,6 +8,10 @@ font-weight: bold; } +.stats-panel-value:not(:first-child) { + padding-left: 20px; +} + .stats-panel-func { font-size: 1.5em; }