You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stats.html.erb 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <h2><%= l(:label_statistics) %></h2>
  2. <div class="repository-graph">
  3. <canvas id="commits_per_month"></canvas>
  4. </div>
  5. <div class="repository-graph">
  6. <canvas id="commits_per_author"></canvas>
  7. </div>
  8. <%= javascript_tag do %>
  9. $(document).ready(function(){
  10. $.getJSON(<%= raw url_for(:controller => 'repositories',
  11. :action => 'graph', :id => @project,
  12. :repository_id => @repository.identifier_param,
  13. :graph => "commits_per_month").to_json %>, function(data){
  14. var chartData = {
  15. labels: data['labels'],
  16. datasets: [{
  17. label: <%= raw l(:label_revision_plural).to_json %>,
  18. backgroundColor: 'rgba(255, 99, 132, 0.7)',
  19. borderColor: 'rgb(255, 99, 132)',
  20. borderWidth: 1,
  21. data: data['commits']
  22. }, {
  23. label: <%= raw l(:label_change_plural).to_json %>,
  24. backgroundColor: 'rgba(54, 162, 235, 0.7)',
  25. borderColor: 'rgb(54, 162, 235)',
  26. data: data['changes']
  27. }]
  28. };
  29. new Chart(document.getElementById("commits_per_month").getContext("2d"), {
  30. type: 'bar',
  31. data: chartData,
  32. options: {
  33. elements: {
  34. rectangle: {borderWidth: 2}
  35. },
  36. responsive: true,
  37. legend: {position: 'right'},
  38. title: {
  39. display: true,
  40. text: <%= raw l(:label_commits_per_month).to_json %>
  41. }
  42. }
  43. });
  44. });
  45. $.getJSON(<%= raw url_for(:controller => 'repositories',
  46. :action => 'graph', :id => @project,
  47. :repository_id => @repository.identifier_param,
  48. :graph => "commits_per_author").to_json %>, function(data){
  49. var chartData = {
  50. labels: data['labels'],
  51. datasets: [{
  52. label: <%= raw l(:label_revision_plural).to_json %>,
  53. backgroundColor: 'rgba(255, 99, 132, 0.7)',
  54. borderColor: 'rgb(255, 99, 132)',
  55. borderWidth: 1,
  56. data: data['commits']
  57. }, {
  58. label: <%= raw l(:label_change_plural).to_json %>,
  59. backgroundColor: 'rgba(54, 162, 235, 0.7)',
  60. borderColor: 'rgb(54, 162, 235)',
  61. data: data['changes']
  62. }]
  63. };
  64. new Chart(document.getElementById("commits_per_author").getContext("2d"), {
  65. type: 'horizontalBar',
  66. data: chartData,
  67. options: {
  68. elements: {
  69. rectangle: {borderWidth: 2}
  70. },
  71. responsive: true,
  72. legend: {position: 'right'},
  73. title: {
  74. display: true,
  75. text: <%= raw l(:label_commits_per_author).to_json %>
  76. }
  77. }
  78. });
  79. });
  80. });
  81. <% end %>
  82. <p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
  83. <% html_title(l(:label_repository), l(:label_statistics)) -%>
  84. <% content_for :header_tags do %>
  85. <%= javascript_include_tag "Chart.bundle.min" %>
  86. <% end %>