Advertisement
pendekar_langit

lontong kapten

Feb 11th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.         'use strict';
  3.  
  4.         var app = angular.module('lbn-app', ['ng.epoch','n3-pie-chart', 'nvd3']);
  5.  
  6.         app.controller('pie-controller',
  7.             function ($scope, $http) {
  8.                 $scope.cpu = [
  9.                 {label: "CPU", value: 75, suffix: "%", color: "steelblue"}
  10.                 ];
  11.                 $scope.ram = [
  12.                 {label: "RAM", value: 30, suffix: "%", color: "red"}
  13.                 ];
  14.                 $scope.disk = [
  15.                 {label: 'DISK', value: 20, suffix: "%", color: "green"}
  16.                 ]
  17.                 $scope.options = {thickness: 3, mode: "gauge", total: 100};
  18.                 var url = "http://localhost:8000/service/";
  19.                 setTimeout(function() {
  20.                     $http.get(url).success( function(response) {
  21.                         $scope.cpu[0].value = response.cpu
  22.                         $scope.ram[0].value = response.ram
  23.                         $scope.disk[0].value = response.disk
  24.                         $scope.data_line = response.net
  25.                     });
  26.                 }, 1000);
  27.             });
  28.          app.controller('line-controller',
  29.             function ($scope, $http) {
  30.                 var url = "http://localhost:8000/service/";
  31.                 // nvd3
  32.                 $scope.options_line = {
  33.                     chart: {
  34.                         type: 'cumulativeLineChart',
  35.                         height: 450,
  36.                         margin : {
  37.                             top: 20,
  38.                             right: 20,
  39.                             bottom: 50,
  40.                             left: 65
  41.                         },
  42.                         x: function(d){ return d[0]; },
  43.                         y: function(d){ return d[1]; },
  44.                         average: function(d) { return d.mean; },
  45.  
  46.                         color: d3.scale.category10().range(),
  47.                         duration: 300,
  48.                         useInteractiveGuideline: true,
  49.                         clipVoronoi: false,
  50.  
  51.                         xAxis: {
  52.                             axisLabel: 'Minutes',
  53.                             tickFormat: function(d) {
  54.                                 return d3.time.format('%M:%S')(new Date(d))
  55.                             },
  56.                             showMaxMin: false,
  57.                             staggerLabels: true
  58.                         },
  59.  
  60.                         yAxis: {
  61.                             axisLabel: 'Bandwidth',
  62.                             tickFormat: function(d){
  63.                                 return d3.format(',.1f')(d)+"kB/s";
  64.                             },
  65.                             axisLabelDistance: 0
  66.                         }
  67.                     }
  68.                 };
  69.                 setTimeout(function(){
  70.                     $http.get(url).success( function(response) {
  71.                         $scope.data_line = response.net
  72.                     });
  73.                 }, 100);
  74.             });
  75.         </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement