Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- 'use strict';
- var app = angular.module('lbn-app', ['ng.epoch','n3-pie-chart', 'nvd3']);
- app.controller('pie-controller',
- function ($scope, $http) {
- $scope.cpu = [
- {label: "CPU", value: 75, suffix: "%", color: "steelblue"}
- ];
- $scope.ram = [
- {label: "RAM", value: 30, suffix: "%", color: "red"}
- ];
- $scope.disk = [
- {label: 'DISK', value: 20, suffix: "%", color: "green"}
- ]
- $scope.options = {thickness: 3, mode: "gauge", total: 100};
- var url = "http://localhost:8000/service/";
- setTimeout(function() {
- $http.get(url).success( function(response) {
- $scope.cpu[0].value = response.cpu
- $scope.ram[0].value = response.ram
- $scope.disk[0].value = response.disk
- $scope.data_line = response.net
- });
- }, 1000);
- });
- app.controller('line-controller',
- function ($scope, $http) {
- var url = "http://localhost:8000/service/";
- // nvd3
- $scope.options_line = {
- chart: {
- type: 'cumulativeLineChart',
- height: 450,
- margin : {
- top: 20,
- right: 20,
- bottom: 50,
- left: 65
- },
- x: function(d){ return d[0]; },
- y: function(d){ return d[1]; },
- average: function(d) { return d.mean; },
- color: d3.scale.category10().range(),
- duration: 300,
- useInteractiveGuideline: true,
- clipVoronoi: false,
- xAxis: {
- axisLabel: 'Minutes',
- tickFormat: function(d) {
- return d3.time.format('%M:%S')(new Date(d))
- },
- showMaxMin: false,
- staggerLabels: true
- },
- yAxis: {
- axisLabel: 'Bandwidth',
- tickFormat: function(d){
- return d3.format(',.1f')(d)+"kB/s";
- },
- axisLabelDistance: 0
- }
- }
- };
- setTimeout(function(){
- $http.get(url).success( function(response) {
- $scope.data_line = response.net
- });
- }, 100);
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement