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
|
|
255 |
hack_hash
|
248 |
256 |
end
|
249 |
257 |
|
250 |
258 |
def graph_commits_per_author(repository)
|
... | ... | |
264 |
272 |
|
265 |
273 |
# Remove email adress in usernames
|
266 |
274 |
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
|
275 |
|
|
276 |
# deal with a large amount of users
|
|
277 |
if fields.length > 10 then
|
|
278 |
graph_height = fields.length * 15
|
|
279 |
else
|
|
280 |
graph_height = 400
|
|
281 |
end
|
267 |
282 |
|
268 |
283 |
graph = SVG::Graph::BarHorizontal.new(
|
269 |
|
:height => 400,
|
|
284 |
:height => graph_height,
|
270 |
285 |
:width => 800,
|
271 |
286 |
:fields => fields,
|
272 |
287 |
:stack => :side,
|
... | ... | |
287 |
302 |
:title => l(:label_change_plural)
|
288 |
303 |
)
|
289 |
304 |
|
290 |
|
graph.burn
|
|
305 |
# hack to get graph height back easily
|
|
306 |
hack_hash = {}
|
|
307 |
hack_hash[:graph_data] = graph.burn
|
|
308 |
hack_hash[:graph_height] =graph_height
|
|
309 |
hack_hash
|
291 |
310 |
end
|
292 |
311 |
|
293 |
312 |
end
|