25 |
25 |
<% end %>
|
26 |
26 |
</tbody>
|
27 |
27 |
</table>
|
|
28 |
<div class="report-bar-graph">
|
|
29 |
<canvas id="issues_per_status"></canvas>
|
|
30 |
</div>
|
|
31 |
<%= javascript_tag do %>
|
|
32 |
$(document).ready(function(){
|
|
33 |
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)'];
|
|
34 |
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)'];
|
|
35 |
var chartData = {
|
|
36 |
labels: <%= raw rows.collect{|row| row.name}.to_json %>,
|
|
37 |
datasets: <%= raw @statuses.collect{|status| {"label" => status.name, "data" => rows.collect{|row| aggregate(data, {field_name => row.id, "status_id" => status.id})}}}.to_json %>
|
|
38 |
};
|
|
39 |
for (var i = 0; i < chartData.datasets.length; i++) {
|
|
40 |
chartData.datasets[i].backgroundColor = backgroundColors[i % backgroundColors.length];
|
|
41 |
chartData.datasets[i].borderColor = borderColors[i % borderColors.length];
|
|
42 |
chartData.datasets[i].borderWidth = 1;
|
|
43 |
}
|
|
44 |
new Chart($('#issues_per_status'), {
|
|
45 |
type: 'horizontalBar',
|
|
46 |
data: chartData,
|
|
47 |
options: {
|
|
48 |
elements: {
|
|
49 |
rectangle: {borderWidth: 2}
|
|
50 |
},
|
|
51 |
responsive: true,
|
|
52 |
legend: {position: 'right'},
|
|
53 |
scales: {
|
|
54 |
yAxes: [{ stacked: true }],
|
|
55 |
xAxes: [{ stacked: true }]
|
|
56 |
}
|
|
57 |
}
|
|
58 |
});
|
|
59 |
});
|
|
60 |
<% end %>
|
|
61 |
<% content_for :header_tags do %>
|
|
62 |
<%= javascript_include_tag "Chart.bundle.min" %>
|
|
63 |
<% end %>
|
28 |
64 |
<% end %>
|