def burn_down_graph(size)
begin
require 'gruff'
rescue MissingSourceFile => e
return File.read("public/images/rmagick_#{size}.gif") if File.exists? "public/images/rmagick_#{size}.gif"
return File.read("public/images/rmagick.gif")
end
g = Gruff::Line.new(size)
g.theme_37signals
g.title = l(:burn_down_chart) + " " + name
g.font = '/usr/share/fonts/bitstream-vera/Vera.ttf'
g.legend_font_size = 14
g.hide_dots = true
g.colors = %w{blue orange}
if track_work?
g.colors += %w{green}
end
if previous_period = higher_item
g.colors += %w{grey grey}
end
if active?
g.colors += %w{lightblue #d7a790}
end
recorded_dates = self.recorded_dates
observed_todo_data = get_todo_data(recorded_dates)
actual_todo_data = get_todo_data(recorded_dates, true)
g.data("#{l :todo} (#{l :obs})", observed_todo_data)
g.data("#{l :todo}", actual_todo_data)
g.data(l(:done), get_work_data(recorded_dates)) if track_work?
if previous_period = higher_item
g.data("#{l :previous_abr} #{l :obs}", previous_period.get_todo_data(previous_period.dates))
g.data("#{l :previous_abr}", previous_period.get_todo_data(previous_period.dates, true))
end
if active?
g.data(l(:projection), projection_data(observed_todo_data))
g.data(l(:projection), projection_data(actual_todo_data))
end
g.minimum_value = 0
all_dates = dates
labels = {1 => all_dates[1].to_s, all_dates.length-1 => all_dates.last.to_s}
labels.merge({all_dates.index(Date.today) => Date.today.to_s}) if all_dates.index(Date.today) && (all_dates.index(Date.today) / all_dates.length) > 0.10
g.labels = labels
g.maximum_value = (g.maximum_value.to_s[0..0].to_i + 1) * (10**Math::log10(g.maximum_value.to_i).to_i) if g.maximum_value > 0
g.to_blob
end