Project

General

Profile

Defect #1983 » quick_hack.patch

David Kowis, 2008-10-03 04:34

View differences:

app/controllers/repositories_controller.rb
165 165
    when "commits_per_author"
166 166
      data = graph_commits_per_author(@repository)
167 167
    end
168
    if data
168
    if data[:graph_data]
169 169
      headers["Content-Type"] = "image/svg+xml"
170
      send_data(data, :type => "image/svg+xml", :disposition => "inline")
170
	  params[:height] = data[:graph_height]
171
      send_data(data[:graph_data], :type => "image/svg+xml", :disposition => "inline")
171 172
    else
172 173
      render_404
173 174
    end
......
221 222
    fields = []
222 223
    month_names = l(:actionview_datehelper_select_month_names_abbr).split(',')
223 224
    12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]}
225

  
226
	#doing this for consistency with the commits_per_author
227
	graph_height = 300
224 228
  
225 229
    graph = SVG::Graph::Bar.new(
226
      :height => 300,
230
      :height => graph_height,
227 231
      :width => 800,
228 232
      :fields => fields.reverse,
229 233
      :stack => :side,
......
244 248
      :title => l(:label_change_plural)
245 249
    )
246 250
    
247
    graph.burn
251
	# hack to get graph height back easily
252
	hack_hash = {}
253
	hack_hash[:graph_data] = graph.burn
254
	hack_hash[:graph_height] =graph_height
248 255
  end
249 256

  
250 257
  def graph_commits_per_author(repository)
......
264 271
    
265 272
    # Remove email adress in usernames
266 273
    fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
274

  
275
	# deal with a large amount of users
276
	if fields.length > 10 then
277
		graph_height = fields.length * 15
278
	else
279
		graph_height = 400
280
	end
267 281
    
268 282
    graph = SVG::Graph::BarHorizontal.new(
269
      :height => 400,
283
      :height => graph_height,
270 284
      :width => 800,
271 285
      :fields => fields,
272 286
      :stack => :side,
......
287 301
      :title => l(:label_change_plural)
288 302
    )
289 303
       
290
    graph.burn
304
	# hack to get graph height back easily
305
	hack_hash = {}
306
	hack_hash[:graph_data] = graph.burn
307
	hack_hash[:graph_height] =graph_height
291 308
  end
292 309

  
293 310
end
app/views/repositories/stats.rhtml
1 1
<h2><%= l(:label_statistics) %></h2>
2 2

  
3 3
<p>
4
<%= tag("embed", :width => 800, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_month")) %>
4
<%= tag("embed", :width => 800, :height => params[:height], :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_month")) %>
5 5
</p>
6 6
<p>
7
<%= tag("embed", :width => 800, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_author")) %>
7
<%= tag("embed", :width => 800, :height => params[:height], :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_author")) %>
8 8
</p>
9 9

  
10 10
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
(1-1/4)