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 commits.map(&:date).minmax
end end
def commits_count_by_author def commits_count_by_author(limit = 4)
Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..5]] Hash[authors.map { |author| [author, author.commits.size] }.sort_by { |author, commits| -commits }[0..limit]]
end end
def lines_added_by_author def lines_added_by_author(limit = 4)
Hash[authors.map { |author| [author, author.lines_added] }.sort_by { |author, lines| -lines }[0..5]] Hash[authors.map { |author| [author, author.lines_added] }.sort_by { |author, lines| -lines }[0..limit]]
end end
def lines_deleted_by_author def lines_deleted_by_author(limit = 4)
Hash[authors.map { |author| [author, author.lines_deleted] }.sort_by { |author, lines| -lines }[0..5]] Hash[authors.map { |author| [author, author.lines_deleted] }.sort_by { |author, lines| -lines }[0..limit]]
end end
def files_count_by_date def files_count_by_date

View file

@ -6,30 +6,30 @@ module GitStats
@authors = authors @authors = authors
end end
def commits_sum_by_author_by_date def commits_sum_by_author_by_date(limit = 4)
Chart.new do |f| Chart.new do |f|
f.multi_date_chart( 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, title: :lines_by_date.t,
y_text: :lines.t y_text: :lines.t
) )
end end
end end
def lines_added_by_author_by_date def lines_added_by_author_by_date(limit = 4)
Chart.new do |f| Chart.new do |f|
f.multi_date_chart( 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, title: :lines_by_date.t,
y_text: :lines.t y_text: :lines.t
) )
end end
end end
def lines_deleted_by_author_by_date def lines_deleted_by_author_by_date(limit = 4)
Chart.new do |f| Chart.new do |f|
f.multi_date_chart( 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, title: :lines_by_date.t,
y_text: :lines.t y_text: :lines.t
) )

View file

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