1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
Kanboard.Analytic = (function() {
return {
Init: function() {
if (Kanboard.Exists("analytic-task-repartition")) {
Kanboard.Analytic.TaskRepartition.Init();
}
else if (Kanboard.Exists("analytic-user-repartition")) {
Kanboard.Analytic.UserRepartition.Init();
}
}
};
})();
Kanboard.Analytic.TaskRepartition = (function() {
function fetchData()
{
jQuery.getJSON($("#chart").attr("data-url"), function(data) {
drawGraph(data.metrics, data.labels);
});
}
function drawGraph(metrics, labels)
{
var series = prepareSeries(metrics, labels);
var svg = dimple.newSvg("#chart", 700, 350);
var chart = new dimple.chart(svg, series);
chart.addMeasureAxis("p", labels["nb_tasks"]);
var ring = chart.addSeries(labels["column_title"], dimple.plot.pie);
ring.innerRadius = "50%";
chart.addLegend(0, 0, 100, 100, "left");
chart.draw();
}
function prepareSeries(metrics, labels)
{
var series = [];
for (var i = 0; i < metrics.length; i++) {
var serie = {};
serie[labels["nb_tasks"]] = metrics[i]["nb_tasks"];
serie[labels["column_title"]] = metrics[i]["column_title"];
series.push(serie);
}
return series;
}
return {
Init: fetchData
};
})();
Kanboard.Analytic.UserRepartition = (function() {
function fetchData()
{
jQuery.getJSON($("#chart").attr("data-url"), function(data) {
drawGraph(data.metrics, data.labels);
});
}
function drawGraph(metrics, labels)
{
var series = prepareSeries(metrics, labels);
var svg = dimple.newSvg("#chart", 700, 350);
var chart = new dimple.chart(svg, series);
chart.addMeasureAxis("p", labels["nb_tasks"]);
var ring = chart.addSeries(labels["user"], dimple.plot.pie);
ring.innerRadius = "50%";
chart.addLegend(0, 0, 100, 100, "left");
chart.draw();
}
function prepareSeries(metrics, labels)
{
var series = [];
for (var i = 0; i < metrics.length; i++) {
var serie = {};
serie[labels["nb_tasks"]] = metrics[i]["nb_tasks"];
serie[labels["user"]] = metrics[i]["user"];
series.push(serie);
}
return series;
}
return {
Init: fetchData
};
})();
|