Gruff

I have installed Gruff and am trying to get an example to work i found
at
http://tomcopeland.blogs.com/juniordeveloper/2006/02/charts_and_grap.html.

I have the following code in the controller:

Send a graph to the browser

def crumpetchartaction
days = 5
g = Gruff::Line.new(500)
g.title = “Crumpets over the past #{days} days”
g.theme_keynote
crumpets_to_date = []
labels = {}
days.downto(0) do |day|
date_stamp = Time.now - (606024*day)
date_sql_string = date_stamp.strftime(“%Y-%m-%d”)
crumpets_to_date << Crumpets.count(“created_on <
‘#{date_sql_string}’”).to_i
labels[days-day] = date_stamp.strftime(“%b %d”) if day % 3 == 0
end

g.data("Crumpets Sold", crumpets_to_date)
g.labels = labels
send_data(g.to_blob, 	:disposition => 'inline', 	:type => 

‘image/png’, :filename => “crumpets_over_time.png”)

end

How do i display this graph in the view???

On Sat, 2006-04-22 at 12:14 +0200, Johnny B wrote:

I have installed Gruff and am trying to get an example to work i found
at
http://tomcopeland.blogs.com/juniordeveloper/2006/02/charts_and_grap.html.

Cool, glad that’s proving useful!

How do i display this graph in the view???

Precisely. At least, that works for me. And you can always check it in
the browser manually by just going to:

http://yourhost/blog/crumpetchartaction

and seeing if the graph shows up.

Yours,

Tom