legend in multidate charts

This commit is contained in:
Tomasz Gieniusz 2012-10-21 18:25:11 +02:00
parent 8138c85a3b
commit 81ad4e0e42
3 changed files with 14 additions and 12 deletions

View file

@ -37,16 +37,16 @@ module GitStats
commits.map(&:date).minmax
end
def commits_count_by_author
Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..5]]
def commits_count_by_author(limit = 4)
Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..limit]]
end
def lines_added_by_author
Hash[authors.map { |author| [author, author.lines_added] }.sort_by { |author, lines| -lines }[0..5]]
def lines_added_by_author(limit = 4)
Hash[authors.map { |author| [author, author.lines_added] }.sort_by { |author, lines| -lines }[0..limit]]
end
def lines_deleted_by_author
Hash[authors.map { |author| [author, author.lines_deleted] }.sort_by { |author, lines| -lines }[0..5]]
def lines_deleted_by_author(limit = 4)
Hash[authors.map { |author| [author, author.lines_deleted] }.sort_by { |author, lines| -lines }[0..limit]]
end
def files_count_by_date

View file

@ -6,30 +6,30 @@ module GitStats
@authors = authors
end
def commits_sum_by_author_by_date
def commits_sum_by_author_by_date(limit = 4)
Chart.new do |f|
f.multi_date_chart(
data: @authors.sort_by { |author| -author.commits.size }[0..5].map { |author| {name: author.email, data: author.commits_sum_by_date} },
data: @authors.sort_by { |author| -author.commits.size }[0..limit].map { |author| {name: author.email, data: author.commits_sum_by_date} },
title: :lines_by_date.t,
y_text: :lines.t
)
end
end
def lines_added_by_author_by_date
def lines_added_by_author_by_date(limit = 4)
Chart.new do |f|
f.multi_date_chart(
data: @authors.sort_by { |author| -author.lines_added }[0..5].map { |author| {name: author.email, data: author.lines_added_by_date} },
data: @authors.sort_by { |author| -author.lines_added }[0..limit].map { |author| {name: author.email, data: author.lines_added_by_date} },
title: :lines_by_date.t,
y_text: :lines.t
)
end
end
def lines_deleted_by_author_by_date
def lines_deleted_by_author_by_date(limit = 4)
Chart.new do |f|
f.multi_date_chart(
data: @authors.sort_by { |author| -author.lines_deleted }[0..5].map { |author| {name: author.email, data: author.lines_deleted_by_date} },
data: @authors.sort_by { |author| -author.lines_deleted }[0..limit].map { |author| {name: author.email, data: author.lines_deleted_by_date} },
title: :lines_by_date.t,
y_text: :lines.t
)

View file

@ -43,6 +43,7 @@ module GitStats
def multi_date_chart(params)
common_options(params)
default_legend
params[:data].each do |s|
series(
name: s[:name],
@ -60,6 +61,7 @@ module GitStats
def default_legend
legend(
enabled: true,
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'left',