diff options
| author | ARC <arjunrc@gmail.com> | 2015-04-26 15:36:10 -0400 |
|---|---|---|
| committer | ARC <arjunrc@gmail.com> | 2015-04-26 15:36:10 -0400 |
| commit | 92e7b14884bd51a2c3b0bbe2f8ad39eaed104880 (patch) | |
| tree | 4425b11c05aa558ca299bd1043121a108fe07ec0 /www/js/EventsGraphsCtrl.js | |
| parent | 2d88cc159325391f29c1bc4f861bae11af5dee04 (diff) | |
Graph height is now a function of number of bars to show (but minimum is always device height)
Diffstat (limited to 'www/js/EventsGraphsCtrl.js')
| -rw-r--r-- | www/js/EventsGraphsCtrl.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js index 92cd525e..8a082db5 100644 --- a/www/js/EventsGraphsCtrl.js +++ b/www/js/EventsGraphsCtrl.js @@ -34,6 +34,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio $scope.chartObject.type = "BarChart"; $scope.chartObject.options = { title: chartTitle, + height: $rootScope.devHeight, // FIXME: I need to make this dynamic depending on // # of bars legend: 'none', @@ -52,7 +53,12 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio ZMDataModel.getMonitors(0).then(function (data) { monitors = data; - + var adjustedHeight = monitors.length * 30; + if (adjustedHeight > $rootScope.devHeight) + { + console.log ("Readjusting chart height to " + adjustedHeight + " pixels"); + $scope.chartObject.options.height = adjustedHeight; + } for (var i = 0; i < monitors.length; i++) { (function (j) { // loop closure - http is async, so success returns after i goes out of scope // so we need to bind j to i when http returns so its not out of scope. Gak. @@ -62,6 +68,8 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio "/events/index/MonitorId:" + monitors[j].Monitor.Id + // FIXME: need to add hr/week ".json?page=1"; console.log("Monitor event URL:" + url); + if (!ZMDataModel.isSimulated()) + { $http.get(url) .success(function (data) { console.log("**** EVENT COUNT FOR MONITOR " + @@ -84,7 +92,14 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio 0, 'opacity: 0.4', 0]); }); - + } // is not simulated + else // grab a random event count + { + var rndEventCount = Math.floor(Math.random() * (100 - 20 + 1)) + 20; + $scope.chartObject.data.push([monitors[j].Monitor.Name, rndEventCount, + 'opacity: 0.4', rndEventCount]); + + } })(i); // j } //for |
