summaryrefslogtreecommitdiff
path: root/www/js/EventsGraphsCtrl.js
diff options
context:
space:
mode:
authorARC <arjunrc@gmail.com>2015-04-25 10:25:29 -0400
committerARC <arjunrc@gmail.com>2015-04-25 10:25:29 -0400
commit30bbcb709ee2caa3fe5edd7ef1169b67b9b132ed (patch)
tree4e1f903505ee52519f3b0e7087588a061a5d8b98 /www/js/EventsGraphsCtrl.js
parent0eae51a295567ca1969313c76d6aa27590c2d27c (diff)
Separated out the charting job into a function and linked chart generation to tab-on-select
Diffstat (limited to 'www/js/EventsGraphsCtrl.js')
-rw-r--r--www/js/EventsGraphsCtrl.js86
1 files changed, 10 insertions, 76 deletions
diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js
index 2bd04e12..9dbf3efb 100644
--- a/www/js/EventsGraphsCtrl.js
+++ b/www/js/EventsGraphsCtrl.js
@@ -12,82 +12,10 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio
}
}];
- $scope.anotherChart = function()
+ $scope.generateChart = function(chartTitle)
{
//alert ("Well I got called!");
- $scope.chart2Object = {}; //test
- $scope.chart2Object.data = [
- ['Monitor', 'Events', {
- role: 'style'
- }, {
- role: 'annotation'
- }],
- ['', 0, '', ''] // needed to get rid of the initial error of charts
- ];
-
-
- $scope.chart2Object.type = "BarChart";
- $scope.chart2Object.options = {
- title: 'Events per monitor PER HOUR',
- height: $rootScope.devHeight,
- animation: {
- duration: 700,
- easing: 'out',
- startup: 'false',
- },
-
-
- }
-
- var monitors = [];
- console.log("*** Grabbing lists of events and monitors ");
- ZMDataModel.getMonitors(0).then(function (data) {
-
- monitors = data;
- var loginData = ZMDataModel.getLogin();
- //var events = ZMDataModel.getAllPreexistingEvents();
- // lets get the event count for all
- for (var i = 0; i < monitors.length; i++) {
- (function (j) {
- //monevents[monitors[j].Monitor.Id].monName = monitors[j].Monitor.Name;
-
- var url = loginData.apiurl +
- "/events/index/MonitorId:" + monitors[j].Monitor.Id +
- ".json?page=1";
- console.log("Monitor event URL:" + url);
- $http.get(url)
- .success(function (data) {
- console.log("**** EVENT COUNT FOR MONITOR " +
- monitors[j].Monitor.Id + " IS " + data.pagination.count);
-
- console.log("Pushing " + monitors[j].Monitor.Name +
- " AND " + data.pagination.count);
-
- $scope.chart2Object.data.push
- ([monitors[j].Monitor.Name, data.pagination.count,
- 'opacity: 0.4', data.pagination.count]);
-
- })
- .error(function (data) {
- console.log("**** EVENT COUNT FOR MONITOR " +
- monitors[i].Monitor.Id + " IS ERROR ");
- $scope.chart2Object.data.push([monitors[j].Monitor.Name,
- 0, 'opacity: 0.4', 0]);
-
- });
-
- })(i); // j
-
- } //for
-
- });
-
- }; // scope function
-
-
-
-
- $scope.chartObject = {}; //test
+ $scope.chartObject = {}; //test
$scope.chartObject.data = [
['Monitor', 'Events', {
role: 'style'
@@ -100,7 +28,7 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio
$scope.chartObject.type = "BarChart";
$scope.chartObject.options = {
- title: 'Events per monitor',
+ title: chartTitle,
height: $rootScope.devHeight,
animation: {
duration: 700,
@@ -154,4 +82,10 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', functio
});
-}); \ No newline at end of file
+ }; // scope function
+
+
+
+
+
+});