1 |
46770
|
sandro.lab
|
/**
|
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 |
|
|
// var timeStats = ['x'];
|
84 |
|
|
// var links = {}
|
85 |
|
|
// var objects = {}
|
86 |
|
|
// for (var key in stats) {
|
87 |
|
|
// timeStats.push(key.substr(0, 10));
|
88 |
|
|
// var currentStats = stats[key];
|
89 |
|
|
// for (var i = 0; i < currentStats.length; i++) {
|
90 |
|
|
// var datasource = currentStats[i]['datasource'];
|
91 |
|
|
// if (!links.hasOwnProperty(datasource)) {
|
92 |
|
|
// links[datasource] = [datasource];
|
93 |
|
|
// }
|
94 |
|
|
// links[datasource].push(currentStats[i]['numberOfRelations']);
|
95 |
|
|
//
|
96 |
|
|
// if (!objects.hasOwnProperty(datasource)) {
|
97 |
|
|
// objects[datasource] = [datasource];
|
98 |
|
|
// }
|
99 |
|
|
// objects[datasource].push(currentStats[i]['numberOfObjects']);
|
100 |
|
|
//
|
101 |
|
|
//
|
102 |
|
|
// }
|
103 |
|
|
// }
|
104 |
|
|
|
105 |
|
|
$scope.historyLinks = data['historyLinks'];
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
$scope.historyObjects = data['historyObjects'];
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
var chart = c3.generate({
|
112 |
|
|
bindto: '#chart_history_links',
|
113 |
|
|
data: {
|
114 |
|
|
x: 'x',
|
115 |
|
|
// xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
|
116 |
|
|
columns: $scope.historyLinks
|
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 |
|
|
|
133 |
|
|
|
134 |
|
|
var chart2 = c3.generate({
|
135 |
|
|
bindto: '#chart_history_objects',
|
136 |
|
|
data: {
|
137 |
|
|
x: 'x',
|
138 |
|
|
// xFormat: '%Y%m%d', // 'xFormat' can be used as custom format of 'x'
|
139 |
|
|
columns: $scope.historyObjects
|
140 |
|
|
},
|
141 |
|
|
axis: {
|
142 |
|
|
x: {
|
143 |
|
|
type: 'timeseries',
|
144 |
|
|
height: 60,
|
145 |
|
|
|
146 |
|
|
tick: {
|
147 |
|
|
format: '%Y-%m-%d',
|
148 |
|
|
rotate: -45
|
149 |
|
|
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
}
|
153 |
|
|
});
|
154 |
|
|
});
|
155 |
|
|
}]);
|