SHARE
TWEET

Untitled

a guest May 26th, 2016 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function () {
  2.     var app = angular.module('dynamoReports');
  3.  
  4.     function dynamoGrapherController($scope, $http) {
  5. /*        $scope.dataFromPromise =
  6.             $http
  7.                 .get('http://localhost:3000/sessions/')
  8.                 .then(function (response) {
  9.                     console.log('response', response);
  10.                     var data = response.data.items;
  11.                     var dataPoints = [];
  12.                     data.forEach(function (item) {
  13.                         item = JSON.parse(item.ADDITIONAL_INFO);
  14.                         var assignmentType = item.assignmentType;
  15.                         if (dataPoints[assignmentType]) {
  16.                             dataPoints[assignmentType] += 1
  17.                         } else {
  18.                             dataPoints[assignmentType] = 1;
  19.  
  20.                         }
  21.                     });
  22.                     var chartData = [];
  23.                     for (key in dataPoints) {
  24.                         chartData.push({Assignment: key, Count: dataPoints[key]});
  25.                     }
  26.                     console.log('chart data', chartData);
  27.  
  28.                     return chartData;
  29.                 });
  30. */
  31.  
  32.         $scope.submitGraphRequest = function () {
  33.             var parameters = [];
  34.             $scope.dataFromPromise =
  35.                 $http
  36.                     .get('http://localhost:3000/sessions/')
  37.                     .then(function (response) {
  38.                         console.log('response', response);
  39.                         var data = response.data.items;
  40.                         var dataPoints = [];
  41.                         data.forEach(function (item) {
  42.                             item = JSON.parse(item.ADDITIONAL_INFO);
  43.                             var assignmentType = item.assignmentType;
  44.                             if (dataPoints[assignmentType]) {
  45.                                 dataPoints[assignmentType] += 1
  46.                             } else {
  47.                                 dataPoints[assignmentType] = 1;
  48.  
  49.                             }
  50.                         });
  51.                         var chartData = [];
  52.                         for (key in dataPoints) {
  53.                             chartData.push({Assignment: key, Count: dataPoints[key]});
  54.                         }
  55.                         console.log('chart data', chartData);
  56.  
  57.                         return chartData;
  58.                     });
  59.         };
  60.  
  61.         $scope.amChartOptions = {
  62.             data: $scope.dataFromPromise,
  63.             type: "serial",
  64.             theme: 'blue',
  65.             categoryField: "Assignment",
  66.             rotate: true,
  67.             pathToImages: 'https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.13.0/images/',
  68.             legend: {
  69.                 enabled: true
  70.             },
  71.             chartScrollbar: {
  72.                 enabled: true
  73.             },
  74.             categoryAxis: {
  75.                 gridPosition: "start",
  76.                 parseDates: false
  77.             },
  78.             valueAxes: [{
  79.                 position: "top"
  80.             }],
  81.             graphs: [{
  82.                 type: "column",
  83.                 title: "Count",
  84.                 valueField: "Count",
  85.                 fillAlphas: 1
  86.             }]
  87.         };
  88.  
  89.  
  90.     }
  91.  
  92.  
  93.     app.directive('dynamoGrapher', function () {
  94.         return {
  95.             templateUrl: 'templates/dynamoGrapher.tpl',
  96.             controller: dynamoGrapherController
  97.         }
  98.     });
  99. }());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top