This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit f1739b9c788c9a1eec382790ed85709b4b7d13f8 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Tue May 5 12:17:45 2015 +0200 stat page : stats are calculated after mod selection (hided if stat is NaN) --- static/js/controllers/statsCtrl.js | 38 +++++++++++++++++++++++++++++++++++--- views/stats.html | 17 ++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/static/js/controllers/statsCtrl.js b/static/js/controllers/statsCtrl.js index 46d13ba..2bc98f1 100644 --- a/static/js/controllers/statsCtrl.js +++ b/static/js/controllers/statsCtrl.js @@ -3,18 +3,22 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) for(var i = 0; i < DataHosts.Items.length; i++){ $scope.host_list.push(DataHosts.Items[i]['addr']) } - $scope.mod_list = []; + //selection $scope.selected_host = ''; - $scope.selected_mod = ''; - $scope.selected_period = ''; + //data $scope.stats = {}; $scope.archive = {}; + //calculated statistics + $scope.mean_value = 0; + $scope.standard_derivation = 0; + $scope.slope_lr = 0; + $scope.get_stats = function(){ if($scope.selected_host != null && $scope.selected_host != ''){ var args = {}; @@ -34,6 +38,13 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) } }); + $scope.update_stats = function(){ + $scope.selected_period = ''; + update_mean(); + update_standard_derivation(); + update_slope_of_linear_regression(); + } + $scope.refresh_chart_data = function(){ $scope.config.title = $scope.selected_host; $scope.data.series = [$scope.selected_mod]; @@ -48,6 +59,27 @@ mumApp.controller('statsCtrl', function($scope, $rootScope, $timeout, DataHosts) } }; + $scope.value_is_NaN = function(value){ + return value !== value; + } + + var update_mean = function(){ + $scope.mean_value = $scope.stats[$scope.selected_mod].total / $scope.stats[$scope.selected_mod].nb_check; + } + + var update_standard_derivation = function(){ + var variance = $scope.stats[$scope.selected_mod].M2 / Math.max(1, $scope.stats[$scope.selected_mod].nb_check + 1); + $scope.standard_derivation = Math.sqrt(variance); + } + + var update_slope_of_linear_regression = function(){ + var mX = ($scope.stats[$scope.selected_mod].nb_check + 1) / 2; + var mY = $scope.stats[$scope.selected_mod].total / $scope.stats[$scope.selected_mod].nb_check; + var mX2 = ($scope.stats[$scope.selected_mod].nb_check + 1) * (2 * $scope.stats[$scope.selected_mod].nb_check + 1) / 6; + var mXY = $scope.stats[$scope.selected_mod].lin_reg / $scope.stats[$scope.selected_mod].nb_check; + $scope.slope_lr = (mXY - mX * mY) / (mX2 - mX * mX); + } + $scope.config = { title: '', tooltips: true, diff --git a/views/stats.html b/views/stats.html index a375749..3dd01bb 100644 --- a/views/stats.html +++ b/views/stats.html @@ -16,7 +16,7 @@ <select ng-model="selected_mod" ng-options="mod for mod in mod_list" ng-show="selected_host != ''" - ng-change="selected_period = ''"> + ng-change="update_stats()"> </select> <select ng-model="selected_period" ng-show="selected_mod != ''" @@ -28,6 +28,21 @@ <option value="month">By month</option> <option value="year">By year</option> </select> + <div class="row" + ng-show="selected_mod != ''"> + <div class="col-xs-2" + ng-show="!value_is_NaN(mean_value)"> + Mean value : {{mean_value}} + </div> + <div class="col-xs-2" + ng-show="!value_is_NaN(standard_derivation)"> + Standard derivation : {{standard_derivation}} + </div> + <div class="col-xs-2" + ng-show="!value_is_NaN(slope_lr)"> + Slope of linear regression : {{slope_lr}} + </div> + </div> <div ng-show="selected_period != ''" data-ac-chart="'line'" -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.