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
107
108
109
|
<h2><%= l(:label_statistics) %></h2>
<div class="repository-graph">
<canvas id="commits_per_month"></canvas>
</div>
<div class="repository-graph">
<canvas id="commits_per_author"></canvas>
</div>
<%= javascript_tag do %>
$(document).ready(function(){
$.getJSON(<%= raw url_for(:controller => 'repositories',
:action => 'graph', :id => @project,
:repository_id => @repository.identifier_param,
:graph => "commits_per_month").to_json %>, function(data){
var chartData = {
labels: data['labels'],
datasets: [{
label: <%= raw l(:label_revision_plural).to_json %>,
backgroundColor: 'rgba(255, 99, 132, 0.7)',
borderColor: 'rgb(255, 99, 132)',
borderWidth: 1,
data: data['commits']
}, {
label: <%= raw l(:label_change_plural).to_json %>,
backgroundColor: 'rgba(54, 162, 235, 0.7)',
borderColor: 'rgb(54, 162, 235)',
data: data['changes']
}]
};
new Chart(document.getElementById("commits_per_month").getContext("2d"), {
type: 'bar',
data: chartData,
options: {
elements: {
bar: {borderWidth: 2}
},
responsive: true,
plugins: {
legend: {position: 'right'},
title: {
display: true,
text: <%= raw l(:label_commits_per_month).to_json %>
}
},
scales: {
yAxis: {ticks: {precision: 0}}
}
}
});
});
$.getJSON(<%= raw url_for(:controller => 'repositories',
:action => 'graph', :id => @project,
:repository_id => @repository.identifier_param,
:graph => "commits_per_author").to_json %>, function(data){
var chartData = {
labels: data['labels'],
datasets: [{
label: <%= raw l(:label_revision_plural).to_json %>,
backgroundColor: 'rgba(255, 99, 132, 0.7)',
borderColor: 'rgb(255, 99, 132)',
borderWidth: 1,
data: data['commits']
}, {
label: <%= raw l(:label_change_plural).to_json %>,
backgroundColor: 'rgba(54, 162, 235, 0.7)',
borderColor: 'rgb(54, 162, 235)',
data: data['changes']
}]
};
new Chart(document.getElementById("commits_per_author").getContext("2d"), {
type: 'bar',
data: chartData,
options: {
indexAxis: 'y',
elements: {
bar: {borderWidth: 2}
},
responsive: true,
plugins: {
legend: {position: 'right'},
title: {
display: true,
text: <%= raw l(:label_commits_per_author).to_json %>
}
},
scales: {
xAxis: {ticks: {precision: 0}}
}
}
});
});
});
<% end %>
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
<% html_title(l(:label_repository), l(:label_statistics)) -%>
<% content_for :header_tags do %>
<%= javascript_include_tag "chart.min" %>
<% end %>
|