commits.html.haml 2.5 KB
Newer Older
1 2
- page_title "Commits", "Graphs"
= render "header_title"
C
Christophe Poulette 已提交
3
= render 'head'
4

5
.gray-content-block.append-bottom-default
6 7 8 9
  .tree-ref-holder
    = render 'shared/ref_switcher', destination: 'graphs_commits'
  %ul.breadcrumb.repo-breadcrumb
    = commits_breadcrumbs
10 11

%p.lead
S
Sabba Petri 已提交
12
  Commit statistics for
13
  %strong #{@ref}
D
Dmitriy Zaporozhets 已提交
14
  #{@commits_graph.start_date.strftime('%b %d')} - #{@commits_graph.end_date.strftime('%b %d')}
15 16 17 18 19 20

.row
  .col-md-6
    %ul
      %li
        %p.lead
D
Dmitriy Zaporozhets 已提交
21
          %strong #{@commits_graph.commits.size}
22
          commits during
D
Dmitriy Zaporozhets 已提交
23
          %strong #{@commits_graph.duration}
24 25 26 27
          days
      %li
        %p.lead
          Average
D
Dmitriy Zaporozhets 已提交
28
          %strong #{@commits_graph.commit_per_day}
29 30 31 32
          commits per day
      %li
        %p.lead
          Contributed by
D
Dmitriy Zaporozhets 已提交
33
          %strong #{@commits_graph.authors}
34 35 36 37 38
          authors
  .col-md-6
    %div
      %p.slead
        Commits per day of month
39
      %canvas#month-chart
40 41 42 43 44
.row
  .col-md-6
    %div
      %p.slead
        Commits per day hour (UTC)
45
      %canvas#hour-chart
46 47 48 49
  .col-md-6
    %div
      %p.slead
        Commits per weekday
50
      %canvas#weekday-chart
51

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
:javascript
  var responsiveChart = function (selector, data) {
    var options = { "scaleOverlay": true, responsive: true, pointHitDetectionRadius: 2, maintainAspectRatio: false };
    // get selector by context
    var ctx = selector.get(0).getContext("2d");
    // pointing parent container to make chart.js inherit its width
    var container = $(selector).parent();
    var generateChart = function() {
      selector.attr('width', $(container).width());
      return new Chart(ctx).Bar(data, options);
    };
    // enabling auto-resizing
    $(window).resize(generateChart);
    return generateChart();
  };
67

68 69
  var chartData = function (keys, values) {
    var data = {
70 71 72 73 74 75 76 77 78
      labels : keys,
      datasets : [{
        fillColor : "rgba(220,220,220,0.5)",
        strokeColor : "rgba(220,220,220,1)",
        barStrokeWidth: 1,
        barValueSpacing: 1,
        barDatasetSpacing: 1,
        data : values
      }]
79 80 81
    };
    return data;
  };
82

83 84
  var hourData = chartData(#{@commits_per_time.keys.to_json}, #{@commits_per_time.values.to_json});
  responsiveChart($('#hour-chart'), hourData);
85

86 87
  var dayData = chartData(#{@commits_per_week_days.keys.to_json}, #{@commits_per_week_days.values.to_json});
  responsiveChart($('#weekday-chart'), dayData);
88

89 90
  var monthData = chartData(#{@commits_per_month.keys.to_json}, #{@commits_per_month.values.to_json});
  responsiveChart($('#month-chart'), monthData);