debian-mirror-gitlab/app/views/projects/graphs/charts.html.haml

128 lines
3.6 KiB
Text
Raw Normal View History

2016-06-22 15:30:34 +05:30
- @no_container = true
2017-08-17 22:00:37 +05:30
- page_title "Charts"
- content_for :page_specific_javascripts do
= page_specific_javascript_bundle_tag('common_d3')
= page_specific_javascript_bundle_tag('graphs')
= render "projects/commits/head"
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
.repo-charts{ class: container_class }
%h4.sub-header
Programming languages used in this repository
2015-11-26 14:37:03 +05:30
2017-08-17 22:00:37 +05:30
.row
.col-md-4
%ul.bordered-list
- @languages.each do |language|
%li
%span{ style: "color: #{language[:color]}" }
= icon('circle')
 
= language[:label]
.pull-right
= language[:value]
\%
.col-md-8
%canvas#languages-chart{ height: 400 }
.repo-charts{ class: container_class }
.sub-header-block.border-top
.row.tree-ref-header
.col-md-6
%h4
Commit statistics for
%strong= @ref
#{@commits_graph.start_date.strftime('%b %d')} - #{@commits_graph.end_date.strftime('%b %d')}
.col-md-6
.tree-ref-container
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'graphs_commits'
%ul.breadcrumb.repo-breadcrumb
= commits_breadcrumbs
2015-04-26 12:48:37 +05:30
2016-06-22 15:30:34 +05:30
.row
.col-md-6
2017-08-17 22:00:37 +05:30
%ul.commit-stats
2016-06-22 15:30:34 +05:30
%li
2017-08-17 22:00:37 +05:30
Total:
%strong #{@commits_graph.commits.size} commits
2016-06-22 15:30:34 +05:30
%li
2017-08-17 22:00:37 +05:30
Average per day:
%strong #{@commits_graph.commit_per_day} commits
2016-06-22 15:30:34 +05:30
%li
2017-08-17 22:00:37 +05:30
Authors:
%strong= @commits_graph.authors
2016-06-22 15:30:34 +05:30
.col-md-6
%div
%p.slead
Commits per day of month
%canvas#month-chart
.row
.col-md-6
.col-md-6
%div
%p.slead
Commits per weekday
%canvas#weekday-chart
2017-08-17 22:00:37 +05:30
.row
.col-md-6
.col-md-6
%div
%p.slead
Commits per day hour (UTC)
%canvas#hour-chart
2015-04-26 12:48:37 +05:30
2015-11-26 14:37:03 +05:30
: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());
2016-09-13 17:45:13 +05:30
if (window.innerWidth < 768) {
// Scale fonts if window width lower than 768px (iPad portrait)
options.scaleFontSize = 8
}
2015-11-26 14:37:03 +05:30
return new Chart(ctx).Bar(data, options);
};
// enabling auto-resizing
$(window).resize(generateChart);
return generateChart();
};
2015-04-26 12:48:37 +05:30
2015-11-26 14:37:03 +05:30
var chartData = function (keys, values) {
var data = {
2015-09-25 12:07:36 +05:30
labels : keys,
datasets : [{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
barStrokeWidth: 1,
barValueSpacing: 1,
barDatasetSpacing: 1,
data : values
}]
2015-11-26 14:37:03 +05:30
};
return data;
};
2015-04-26 12:48:37 +05:30
2015-11-26 14:37:03 +05:30
var hourData = chartData(#{@commits_per_time.keys.to_json}, #{@commits_per_time.values.to_json});
responsiveChart($('#hour-chart'), hourData);
2015-09-25 12:07:36 +05:30
2015-11-26 14:37:03 +05:30
var dayData = chartData(#{@commits_per_week_days.keys.to_json}, #{@commits_per_week_days.values.to_json});
responsiveChart($('#weekday-chart'), dayData);
2015-09-25 12:07:36 +05:30
2015-11-26 14:37:03 +05:30
var monthData = chartData(#{@commits_per_month.keys.to_json}, #{@commits_per_month.values.to_json});
responsiveChart($('#month-chart'), monthData);
2017-08-17 22:00:37 +05:30
var data = #{@languages.to_json};
var ctx = $("#languages-chart").get(0).getContext("2d");
var options = {
scaleOverlay: true,
responsive: true,
maintainAspectRatio: false
}
var myPieChart = new Chart(ctx).Pie(data, options);