diff --git a/lib/git_stats/stats_view/view_data.rb b/lib/git_stats/stats_view/view_data.rb index 454dc4afe..258423fcc 100644 --- a/lib/git_stats/stats_view/view_data.rb +++ b/lib/git_stats/stats_view/view_data.rb @@ -10,8 +10,8 @@ module GitStats @repo = repo end - def h - @h ||= LazyHighCharts::HighChart.new('graph') do |f| + def by_wday + @by_wday ||= LazyHighCharts::HighChart.new('graph') do |f| f.chart(type: "column") f.title(text: "Commits") f.xAxis(categories: Date::ABBR_DAYNAMES) @@ -27,10 +27,28 @@ module GitStats shadow: true ) repo.authors.each do |email, author| - f.series(:name => email, :data => author.activity.by_wday.inject([]) { |acc, (k, v)| acc[k] = v; acc }) + f.series(name: email, data: author.activity.by_wday.inject([]) { |acc, (k, v)| acc[k] = v; acc }) end end end + + def files_by_date + @files_by_date ||= LazyHighCharts::HighChart.new('graph') do |f| + f.title(text: "Files") + f.xAxis(type: "datetime") + f.yAxis(min: 0, title: {text: 'Commits'}) + rcommits = repo.commits.reverse + f.series( + type: "area", + name: "commits", + pointInterval: 1.day * 1000, + pointStart: repo.commits.first.date.to_i * 1000, + data: repo.commits.first.date.midnight.upto((repo.commits.last.date + 1.day).midnight).map { |day| + rcommits.find { |c| c.date < day }.files_count rescue 0 + } + ) + end + end end end end \ No newline at end of file diff --git a/templates/authors.haml b/templates/authors.haml index cedf7a3e4..8b48a0de2 100644 --- a/templates/authors.haml +++ b/templates/authors.haml @@ -1 +1 @@ -= high_chart("my_id", h) \ No newline at end of file += high_chart("by_wday", by_wday) \ No newline at end of file diff --git a/templates/files.haml b/templates/files.haml new file mode 100644 index 000000000..9c93e343b --- /dev/null +++ b/templates/files.haml @@ -0,0 +1 @@ += high_chart("files_by_date", files_by_date) \ No newline at end of file