Forum: Ruby on Rails Have a quick Gruff Graphing question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marston A. (Guest)
on 2006-05-26 01:19
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.
David M. (Guest)
on 2006-05-26 01:22
(Received via mailing list)
I've tried to find the same option, but without any luck.

Regards

Dave M.
Marston A. (Guest)
on 2006-05-26 12:52
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.
This topic is locked and can not be replied to.