diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 7857685..edc0a2d 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -165,9 +165,10 @@ class RepositoriesController < ApplicationController when "commits_per_author" data = graph_commits_per_author(@repository) end - if data + if data[:graph_data] headers["Content-Type"] = "image/svg+xml" - send_data(data, :type => "image/svg+xml", :disposition => "inline") + params[:height] = data[:graph_height] + send_data(data[:graph_data], :type => "image/svg+xml", :disposition => "inline") else render_404 end @@ -221,9 +222,12 @@ private fields = [] month_names = l(:actionview_datehelper_select_month_names_abbr).split(',') 12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]} + + #doing this for consistency with the commits_per_author + graph_height = 300 graph = SVG::Graph::Bar.new( - :height => 300, + :height => graph_height, :width => 800, :fields => fields.reverse, :stack => :side, @@ -244,7 +248,10 @@ private :title => l(:label_change_plural) ) - graph.burn + # hack to get graph height back easily + hack_hash = {} + hack_hash[:graph_data] = graph.burn + hack_hash[:graph_height] =graph_height end def graph_commits_per_author(repository) @@ -264,9 +271,16 @@ private # Remove email adress in usernames fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') } + + # deal with a large amount of users + if fields.length > 10 then + graph_height = fields.length * 15 + else + graph_height = 400 + end graph = SVG::Graph::BarHorizontal.new( - :height => 400, + :height => graph_height, :width => 800, :fields => fields, :stack => :side, @@ -287,7 +301,10 @@ private :title => l(:label_change_plural) ) - graph.burn + # hack to get graph height back easily + hack_hash = {} + hack_hash[:graph_data] = graph.burn + hack_hash[:graph_height] =graph_height end end diff --git a/app/views/repositories/stats.rhtml b/app/views/repositories/stats.rhtml index 1e61757..cea70c7 100644 --- a/app/views/repositories/stats.rhtml +++ b/app/views/repositories/stats.rhtml @@ -1,10 +1,10 @@

<%= l(:label_statistics) %>

-<%= tag("embed", :width => 800, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_month")) %> +<%= tag("embed", :width => 800, :height => params[:height], :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_month")) %>

-<%= tag("embed", :width => 800, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_author")) %> +<%= tag("embed", :width => 800, :height => params[:height], :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_author")) %>

<%= link_to l(:button_back), :action => 'show', :id => @project %>