forked from expertiza/expertiza
/
github_metrics_helper.rb
61 lines (57 loc) · 1.33 KB
/
github_metrics_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module GithubMetricsHelper
def display_github_metrics(parsed_data, authors, dates)
data_array = []
color = %w[red yellow blue gray green magenta]
i = 0
authors.each do |author|
data_object = {}
data_object['label'] = author
data_object['data'] = parsed_data[author].values
data_object['backgroundColor'] = color[i]
data_object['borderWidth'] = 1
data_array.push(data_object)
i += 1
i = 0 if i > 5
end
data = {
labels: dates,
datasets: data_array
}
horizontal_bar_chart data, chart_options
end
def chart_options
{
responsive: true,
maintainAspectRatio: false,
width: 100,
height: 100,
scales: graph_scales
}
end
def graph_scales
{
yAxes: [{
stacked: true,
ticks: {
beginAtZero: true
},
barThickness: 30,
scaleLabel: {
display: true,
labelString: 'Submission timeline'
}
}],
xAxes: [{
stacked: true,
ticks: {
beginAtZero: true
},
barThickness: 30,
scaleLabel: {
display: true,
labelString: '# of Commits'
}
}]
}
end
end