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
|
<% if @statuses.empty? or rows.empty? %>
<p><i><%=l(:label_no_data)%></i></p>
<% else %>
<table class="list issue-report">
<thead><tr>
<th></th>
<% for status in @statuses %>
<th><%= status.name %></th>
<% end %>
<th><strong><%=l(:label_open_issues_plural)%></strong></th>
<th><strong><%=l(:label_closed_issues_plural)%></strong></th>
<th><strong><%=l(:label_total)%></strong></th>
</tr></thead>
<tbody>
<% for row in rows %>
<tr>
<td class="name"><%= link_to row.name, aggregate_path(@project, field_name, row, :subproject_id => nil) %></td>
<% for status in @statuses %>
<td><%= aggregate_link data, { field_name => row.id, "status_id" => status.id }, aggregate_path(@project, field_name, row, :status_id => status.id, :subproject_id => nil) %></td>
<% end %>
<td><%= aggregate_link data, { field_name => row.id, "closed" => 0 }, aggregate_path(@project, field_name, row, :status_id => "o", :subproject_id => nil) %></td>
<td><%= aggregate_link data, { field_name => row.id, "closed" => 1 }, aggregate_path(@project, field_name, row, :status_id => "c", :subproject_id => nil) %></td>
<td><%= aggregate_link data, { field_name => row.id }, aggregate_path(@project, field_name, row, :status_id => "*", :subproject_id => nil) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="issue-report-graph">
<canvas id="issues_by_<%= params[:detail] %>"></canvas>
</div>
<div class="issue-report-graph">
<canvas id="issues_by_status"></canvas>
</div>
<%= javascript_tag do %>
function renderChart(canvas_id, title, chartData){
var backgroundColors = ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)'];
var borderColors = ['rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)'];
for (var i = 0; i < chartData.datasets.length; i++) {
chartData.datasets[i].backgroundColor = backgroundColors[i % backgroundColors.length];
chartData.datasets[i].borderColor = borderColors[i % borderColors.length];
chartData.datasets[i].borderWidth = 1;
}
new Chart($(canvas_id), {
type: 'horizontalBar',
data: chartData,
options: {
elements: {
rectangle: {borderWidth: 2}
},
responsive: true,
legend: {position: 'right'},
title: {
display: true,
text: title
},
scales: {
yAxes: [{ stacked: true }],
xAxes: [{ stacked: true }]
}
}
});
}
$(document).ready(function(){
var chartData1 = {
labels: <%= raw rows.collect{|row| row.name}.to_json %>,
datasets: <%= raw @statuses.collect{|status| {"label" => status.name, "hidden" => status.is_closed?, "data" => rows.collect{|row| aggregate(data, {field_name => row.id, "status_id" => status.id})}}}.to_json %>
};
var chartData2 = {
labels: <%= raw @statuses.collect{|status| status.name}.to_json %>,
datasets: <%= raw rows.collect{|row| {"label" => row.name, "data" => @statuses.collect{|status| aggregate(data, {field_name => row.id, "status_id" => status.id})}}}.to_json %>
};
renderChart("#issues_by_<%= params[:detail] %>", "<%= l(:label_issues_by, @report_title) %>", chartData1);
renderChart("#issues_by_status", "<%= l(:label_issues_by, l(:field_status)) %>", chartData2);
});
<% end %>
<% content_for :header_tags do %>
<%= javascript_include_tag "Chart.bundle.min" %>
<% end %>
<% end %>
|