Project

General

Profile

1
/**
2
 * Created by sandro on 11/13/15.
3
 */
4

    
5
dliApp.controller('statsController', ['$scope', "$location", 'queryService', function ($scope, $location, queryService) {
6

    
7
    $scope.stats_objects = [];
8
    $scope.stat_datasets = [];
9
    $scope.stat_publications = [];
10
    $scope.stat_links = [];
11

    
12
    queryService.getStatsDetail().success(function (data) {
13
        $scope.stats = data['stats'];
14

    
15
        for (var i = 0; i < $scope.stats.length; i++) {
16
            var item = $scope.stats[i];
17
            $scope.stat_datasets.push([item['datasource'], item['referredDataset']]);
18
            $scope.stat_publications.push([item['datasource'], item['referredPublication']]);
19
            $scope.stat_links.push([item['datasource'], item['referredUnknown']]);
20
            $scope.stats_objects.push([item['datasource'], item['numberOfObjects']]);
21
        }
22

    
23
        var chart = c3.generate({
24
            bindto: '#chart_dataset',
25
            data: {
26
                columns: $scope.stat_datasets,
27
                type: 'bar'
28
            },
29
            bar: {
30
                width: {
31
                    ratio: 1
32
                }
33
            }
34
        });
35

    
36

    
37
        var chart2 = c3.generate({
38
            bindto: '#chart_publication',
39
            data: {
40
                columns: $scope.stat_publications,
41
                type: 'bar'
42
            },
43
            bar: {
44
                width: {
45
                    ratio: 1
46
                }
47
            }
48
        });
49

    
50

    
51
        var chart3 = c3.generate({
52
            bindto: '#chart_links',
53
            data: {
54
                columns: $scope.stat_links,
55
                type: 'bar'
56
            },
57
            bar: {
58
                width: {
59
                    ratio: 1
60
                }
61
            }
62
        });
63

    
64

    
65
        var chart4 = c3.generate({
66
            bindto: '#chart_objects',
67
            data: {
68
                columns: $scope.stats_objects,
69
                type: 'bar'
70
            },
71
            bar: {
72
                width: {
73
                    ratio: 1
74
                }
75
            }
76
        });
77
        // $('ul.tabs').tabs();
78
    });
79

    
80
    queryService.getStats().success(function (data) {
81
        var stats = data;
82

    
83
        $scope.historyLinks = data['historyLinks'];
84

    
85

    
86
        $scope.historyObjects = data['historyObjects'];
87

    
88

    
89
        var chart = c3.generate({
90
            bindto: '#chart_history_links',
91
            data: {
92
                x: 'x',
93
                columns: $scope.historyLinks
94
            },
95
            axis: {
96
                x: {
97
                    type: 'timeseries',
98
                    height: 60,
99

    
100
                    tick: {
101
                        format: '%Y-%m-%d',
102
                        rotate: -45
103

    
104

    
105
                    }
106
                }
107
            }
108
        });
109

    
110

    
111
        var chart2 = c3.generate({
112
            bindto: '#chart_history_objects',
113
            data: {
114
                x: 'x',
115
//        xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
116
                columns: $scope.historyObjects
117
            },
118
            axis: {
119
                x: {
120
                    type: 'timeseries',
121
                    height: 60,
122

    
123
                    tick: {
124
                        format: '%Y-%m-%d',
125
                        rotate: -45
126

    
127
                    }
128
                }
129
            }
130
        });
131
    });
132
}]);
(7-7/7)