Have a quick Gruff Graphing question


#1

I have some graphs and everything is working great, but I’d like to set
a minimum height so to speak on the vertical scale. Is there a method
to do that with Gruff? I’ve tried looking through the docs but can’t
seem to get it to work.

So for example, if the highest datapoint in my graph was say 500, is it
possible to have the minimum vertical scale on the left set to 800 and
have the bar/line graph scale to it?

My current code looks like this (with the labels and data array
populated elsewhere):

  g = Gruff::Bar.new(750)
  g.title = "12 Month Graph"
  g.labels = title_array.reverse
  g.theme_37signals

  g.data("12 month graph", data.reverse, '#378CDF')

  send_data(g.to_blob, :disposition => 'inline', :type => 

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

Thanks for any help.


#2

I’ve tried to find the same option, but without any luck.

Regards

Dave M.


#3

I finally figured it out after a few hours of searching. What you have
to do is add the “g.maximum_value = ###” statement below your g.data
call but before you g.write or send_data. So now my graph code looks
like this:

  g = Gruff::Bar.new(750)
  g.title = "12 Month Graph"
  g.labels = title_array.reverse
  g.theme_37signals

  g.data("12 Month Graph", data.reverse, '#378CDF')

  g.maximum_value = 600

  send_data(g.to_blob, :disposition => 'inline', :type => 

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

Hope this helps anyone having this question in the future.

David M. wrote:

I’ve tried to find the same option, but without any luck.

Regards

Dave M.