mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 21:42:16 +01:00
repo charts refactored
This commit is contained in:
parent
a69446bed3
commit
9acd9cbfe9
2 changed files with 57 additions and 39 deletions
|
@ -12,6 +12,38 @@ module GitStats
|
||||||
yield self if block_given?
|
yield self if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def column_hash_chart(params)
|
||||||
|
common_params(params)
|
||||||
|
type "column"
|
||||||
|
x_categories params[:data].keys
|
||||||
|
series(name: params[:title], data: params[:data].values)
|
||||||
|
end
|
||||||
|
|
||||||
|
def day_chart(params)
|
||||||
|
common_params(params)
|
||||||
|
type "datetime"
|
||||||
|
series(
|
||||||
|
type: "area",
|
||||||
|
name: "commits",
|
||||||
|
pointInterval: 1.day * 1000,
|
||||||
|
pointStart: params[:start_day].to_i * 1000,
|
||||||
|
data: params[:data]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_legend
|
||||||
|
legend(
|
||||||
|
layout: 'vertical',
|
||||||
|
backgroundColor: '#FFFFFF',
|
||||||
|
align: 'left',
|
||||||
|
verticalAlign: 'top',
|
||||||
|
x: 100,
|
||||||
|
y: 70,
|
||||||
|
floating: true,
|
||||||
|
shadow: true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def type(type)
|
def type(type)
|
||||||
@chart.chart(type: type)
|
@chart.chart(type: type)
|
||||||
end
|
end
|
||||||
|
@ -28,18 +60,12 @@ module GitStats
|
||||||
@chart.title(text: title)
|
@chart.title(text: title)
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_legend
|
private
|
||||||
legend(
|
def common_params(params)
|
||||||
layout: 'vertical',
|
title params[:title]
|
||||||
backgroundColor: '#FFFFFF',
|
y_text params[:y_text]
|
||||||
align: 'left',
|
|
||||||
verticalAlign: 'top',
|
|
||||||
x: 100,
|
|
||||||
y: 70,
|
|
||||||
floating: true,
|
|
||||||
shadow: true
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,50 +8,42 @@ module GitStats
|
||||||
|
|
||||||
def files_by_extension
|
def files_by_extension
|
||||||
Chart.new do |f|
|
Chart.new do |f|
|
||||||
f.type "column"
|
f.column_hash_chart(
|
||||||
f.title "files by extension"
|
data: @repo.files_by_extension_count,
|
||||||
f.x_categories @repo.files_by_extension_count.keys
|
title: "files_by_extension",
|
||||||
f.y_text 'Commits'
|
y_text: "files"
|
||||||
f.series(name: "commits", data: @repo.files_by_extension_count.values)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def lines_by_extension
|
def lines_by_extension
|
||||||
Chart.new do |f|
|
Chart.new do |f|
|
||||||
f.type "column"
|
f.column_hash_chart(
|
||||||
f.title "lines by extension"
|
data: @repo.lines_by_extension,
|
||||||
f.x_categories @repo.lines_by_extension.keys
|
title: "lines_by_extension",
|
||||||
f.y_text 'Commits'
|
y_text: "lines"
|
||||||
f.series(name: "commits", data: @repo.lines_by_extension.values)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def files_by_date
|
def files_by_date
|
||||||
Chart.new do |f|
|
Chart.new do |f|
|
||||||
f.title "Files"
|
f.day_chart(
|
||||||
f.type "datetime"
|
data: @repo.files_count_each_day,
|
||||||
f.y_text 'Commits'
|
start_day: @repo.commits.first.date,
|
||||||
f.series(
|
title: "files_by_date",
|
||||||
type: "area",
|
y_text: "files"
|
||||||
name: "commits",
|
|
||||||
pointInterval: 1.day * 1000,
|
|
||||||
pointStart: @repo.commits.first.date.to_i * 1000,
|
|
||||||
data: @repo.files_count_each_day
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def lines_by_date
|
def lines_by_date
|
||||||
Chart.new do |f|
|
Chart.new do |f|
|
||||||
f.title "Files"
|
f.day_chart(
|
||||||
f.type "datetime"
|
data: @repo.lines_count_each_day,
|
||||||
f.y_text 'Commits'
|
start_day: @repo.commits.first.date,
|
||||||
f.series(
|
title: "lines_by_date",
|
||||||
type: "area",
|
y_text: "lines"
|
||||||
name: "commits",
|
|
||||||
pointInterval: 1.day * 1000,
|
|
||||||
pointStart: @repo.commits.first.date.to_i * 1000,
|
|
||||||
data: @repo.lines_count_each_day
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue