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?
|
||||
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)
|
||||
@chart.chart(type: type)
|
||||
end
|
||||
|
@ -28,18 +60,12 @@ module GitStats
|
|||
@chart.title(text: title)
|
||||
end
|
||||
|
||||
def default_legend
|
||||
legend(
|
||||
layout: 'vertical',
|
||||
backgroundColor: '#FFFFFF',
|
||||
align: 'left',
|
||||
verticalAlign: 'top',
|
||||
x: 100,
|
||||
y: 70,
|
||||
floating: true,
|
||||
shadow: true
|
||||
)
|
||||
end
|
||||
private
|
||||
def common_params(params)
|
||||
title params[:title]
|
||||
y_text params[:y_text]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,50 +8,42 @@ module GitStats
|
|||
|
||||
def files_by_extension
|
||||
Chart.new do |f|
|
||||
f.type "column"
|
||||
f.title "files by extension"
|
||||
f.x_categories @repo.files_by_extension_count.keys
|
||||
f.y_text 'Commits'
|
||||
f.series(name: "commits", data: @repo.files_by_extension_count.values)
|
||||
f.column_hash_chart(
|
||||
data: @repo.files_by_extension_count,
|
||||
title: "files_by_extension",
|
||||
y_text: "files"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def lines_by_extension
|
||||
Chart.new do |f|
|
||||
f.type "column"
|
||||
f.title "lines by extension"
|
||||
f.x_categories @repo.lines_by_extension.keys
|
||||
f.y_text 'Commits'
|
||||
f.series(name: "commits", data: @repo.lines_by_extension.values)
|
||||
f.column_hash_chart(
|
||||
data: @repo.lines_by_extension,
|
||||
title: "lines_by_extension",
|
||||
y_text: "lines"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def files_by_date
|
||||
Chart.new do |f|
|
||||
f.title "Files"
|
||||
f.type "datetime"
|
||||
f.y_text 'Commits'
|
||||
f.series(
|
||||
type: "area",
|
||||
name: "commits",
|
||||
pointInterval: 1.day * 1000,
|
||||
pointStart: @repo.commits.first.date.to_i * 1000,
|
||||
data: @repo.files_count_each_day
|
||||
f.day_chart(
|
||||
data: @repo.files_count_each_day,
|
||||
start_day: @repo.commits.first.date,
|
||||
title: "files_by_date",
|
||||
y_text: "files"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def lines_by_date
|
||||
Chart.new do |f|
|
||||
f.title "Files"
|
||||
f.type "datetime"
|
||||
f.y_text 'Commits'
|
||||
f.series(
|
||||
type: "area",
|
||||
name: "commits",
|
||||
pointInterval: 1.day * 1000,
|
||||
pointStart: @repo.commits.first.date.to_i * 1000,
|
||||
data: @repo.lines_count_each_day
|
||||
f.day_chart(
|
||||
data: @repo.lines_count_each_day,
|
||||
start_day: @repo.commits.first.date,
|
||||
title: "lines_by_date",
|
||||
y_text: "lines"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue