gitlab-org--gitlab-foss/app/views/projects/graphs/commits.html.haml

96 lines
2.7 KiB
Text
Raw Normal View History

2016-06-15 09:54:31 -04:00
- @no_container = true
- page_title "Commits", "Graphs"
2015-11-08 14:31:55 -05:00
= render 'head'
2016-06-30 09:01:26 -04:00
%div{ class: container_class }
.sub-header-block
2016-06-15 09:54:31 -04:00
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'graphs_commits'
%ul.breadcrumb.repo-breadcrumb
= commits_breadcrumbs
2016-06-15 09:54:31 -04:00
%p.lead
Commit statistics for
%strong= @ref
2016-06-15 09:54:31 -04:00
#{@commits_graph.start_date.strftime('%b %d')} - #{@commits_graph.end_date.strftime('%b %d')}
2016-06-15 09:54:31 -04:00
.row
.col-md-6
%ul
%li
%p.lead
%strong= @commits_graph.commits.size
2016-06-15 09:54:31 -04:00
commits during
%strong= @commits_graph.duration
2016-06-15 09:54:31 -04:00
days
%li
%p.lead
Average
%strong= @commits_graph.commit_per_day
2016-06-15 09:54:31 -04:00
commits per day
%li
%p.lead
Contributed by
%strong= @commits_graph.authors
2016-06-15 09:54:31 -04:00
authors
.col-md-6
%div
%p.slead
Commits per day of month
%canvas#month-chart
.row
.col-md-6
%div
%p.slead
Commits per day hour (UTC)
%canvas#hour-chart
.col-md-6
%div
%p.slead
Commits per weekday
%canvas#weekday-chart
: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());
if (window.innerWidth < 768) {
// Scale fonts if window width lower than 768px (iPad portrait)
options.scaleFontSize = 8
}
return new Chart(ctx).Bar(data, options);
};
// enabling auto-resizing
$(window).resize(generateChart);
return generateChart();
};
var chartData = function (keys, values) {
var data = {
labels : keys,
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data : values
}]
};
return data;
};
var hourData = chartData(#{@commits_per_time.keys.to_json}, #{@commits_per_time.values.to_json});
responsiveChart($('#hour-chart'), hourData);
var dayData = chartData(#{@commits_per_week_days.keys.to_json}, #{@commits_per_week_days.values.to_json});
responsiveChart($('#weekday-chart'), dayData);
var monthData = chartData(#{@commits_per_month.keys.to_json}, #{@commits_per_month.values.to_json});
responsiveChart($('#month-chart'), monthData);