mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
i18n in charts
This commit is contained in:
parent
89c27a666e
commit
af3d93aab9
5 changed files with 53 additions and 28 deletions
|
@ -8,3 +8,11 @@ en:
|
|||
total_lines: Total lines
|
||||
total_commits: Total commits
|
||||
authors: Authors
|
||||
commits: Commits
|
||||
commits_by_hour: Commits by hour
|
||||
files: Files
|
||||
lines: Lines
|
||||
files_by_date: Files by date
|
||||
lines_by_date: Lines by date
|
||||
files_by_extension: Files by extension
|
||||
lines_by_extension: Lines by extension
|
|
@ -8,11 +8,12 @@ module GitStats
|
|||
|
||||
def activity_by_hour
|
||||
Chart.new do |f|
|
||||
f.type "column"
|
||||
f.title "Commits"
|
||||
f.x_categories (0..23)
|
||||
f.y_text 'Commits'
|
||||
f.series(name: "commits", data: @activity.by_hour.to_key_indexed_array)
|
||||
f.simple_column_chart(
|
||||
title: :commits_by_hour.t,
|
||||
y_text: :commits.t,
|
||||
data_x: (0..23),
|
||||
data_y: @activity.by_hour.to_key_indexed_array
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,16 +7,14 @@ module GitStats
|
|||
end
|
||||
|
||||
def by_authors_wday
|
||||
Chart.new do |c|
|
||||
c.type "column"
|
||||
c.title 'by_wday_authors'
|
||||
c.x_categories Date::ABBR_DAYNAMES
|
||||
c.y_text 'y_text'
|
||||
c.default_legend
|
||||
|
||||
@authors.each do |author|
|
||||
c.series(name: author.email, data: author.activity.by_wday.to_key_indexed_array)
|
||||
end
|
||||
Chart.new do |f|
|
||||
f.multiple_column_chart(
|
||||
title: :by_authors_wday.t,
|
||||
y_text: :commits.t,
|
||||
data_x: Date::ABBR_DAYNAMES,
|
||||
data_y: @authors.map { |author| {name: author.email, data: author.activity.by_wday.to_key_indexed_array} }
|
||||
)
|
||||
f.default_legend
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,11 +12,24 @@ module GitStats
|
|||
yield self if block_given?
|
||||
end
|
||||
|
||||
def simple_column_chart(params)
|
||||
column_chart(params)
|
||||
series(name: params[:title], data: params[:data_y])
|
||||
end
|
||||
|
||||
def multiple_column_chart(params)
|
||||
column_chart(params)
|
||||
params[:data_y].each do |s|
|
||||
series(name: s[:name], data: s[:data])
|
||||
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)
|
||||
simple_column_chart(params.merge(
|
||||
data_x: params[:data].keys,
|
||||
data_y: params[:data].values
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def day_chart(params)
|
||||
|
@ -66,6 +79,11 @@ module GitStats
|
|||
y_text params[:y_text]
|
||||
end
|
||||
|
||||
def column_chart(params)
|
||||
common_params(params)
|
||||
type "column"
|
||||
x_categories params[:data_x]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,8 +10,8 @@ module GitStats
|
|||
Chart.new do |f|
|
||||
f.column_hash_chart(
|
||||
data: @repo.files_by_extension_count,
|
||||
title: "files_by_extension",
|
||||
y_text: "files"
|
||||
title: :files_by_extension.t,
|
||||
y_text: :files.t
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -20,8 +20,8 @@ module GitStats
|
|||
Chart.new do |f|
|
||||
f.column_hash_chart(
|
||||
data: @repo.lines_by_extension,
|
||||
title: "lines_by_extension",
|
||||
y_text: "lines"
|
||||
title: :lines_by_extension.t,
|
||||
y_text: :lines.t
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -31,8 +31,8 @@ module GitStats
|
|||
f.day_chart(
|
||||
data: @repo.files_count_each_day,
|
||||
start_day: @repo.commits.first.date,
|
||||
title: "files_by_date",
|
||||
y_text: "files"
|
||||
title: :files_by_date.t,
|
||||
y_text: :files.t
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -42,8 +42,8 @@ module GitStats
|
|||
f.day_chart(
|
||||
data: @repo.lines_count_each_day,
|
||||
start_day: @repo.commits.first.date,
|
||||
title: "lines_by_date",
|
||||
y_text: "lines"
|
||||
title: :lines_by_date.t,
|
||||
y_text: :lines.t
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue