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
|