Gruff! Gruff! 5 comments

posted Tuesday, October 25, 2005 by glyph

Initial alpha release now available from RubyForge.

gem install gruff

There are definitely some bugs to work out, but the general output is there and I’ll be adding pie, bar, and area variations later. Graphs look good down to 400px wide, or at the default of 800×600.

Sample script:

#!/usr/bin/ruby

require 'rubygems'
require 'gruff'

g = Gruff::Line.new
g.title = "My Graph" 

g.data("Apples", [1, 2, 3, 4, 4, 3])
g.data("Oranges", [4, 8, 7, 9, 8, 9])
g.data("Watermelon", [2, 3, 1, 5, 6, 8])
g.data("Peaches", [9, 9, 10, 8, 7, 9])

g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}

g.write('my_fruity_graph.png')
5 comments

Leave a response

  • Marcus Ahnve

    When trying out the test script I get the following error:

    NameError: uninitialized constant Gruff::Base at top level in area.rb at line 5 method require__ in custom_require.rb at line 21 method require in custom_require.rb at line 21 at top level in gruff.rb at line 4 method each in gruff.rb at line 2 at top level in gruff.rb at line 2 method require__ in custom_require.rb at line 21 method require in custom_require.rb at line 21 method activate in rubygems.rb at line 182 method each in rubygems.rb at line 181 method activate in rubygems.rb at line 181 method require in custom_require.rb at line 26 at top level in grufftest.rb at line 4

  • Tom

    Nice. Look forward to seeing more of it.

    Had a bit of a problem running the example.

    /ruby/gems/1.8/gems/RMagick-win32-1.9.2-mswin32/lib/rmagick.rb:1002:in `undef_method’: undefined method `assoc’ for class `Magick::ImageList’ (NameError)

    Replacing

    require ‘rmagick’

    in base.rb with

    require ‘RMagick’

    fixed it.

  • Tomas Jogin

    Nice, but what about pie charts and bar charts, eh? Managers LOVE those!

  • Tomas Jogin

    Yeah, ok, I’ll work on my reading skills. Thanks.

  • topfunky

    Tom—

    Thanks for the ‘require’ correction. I’ll add that as a fallback case so it works on Windows as well.

Your Comment

Nuby on Rails

Geoffrey Grosenbach / Ruby / Code / Graphics / Design / Rails / Merb / Javascript / CSS

Ads by The Lounge

Manufactured with

Subscribe

Subscribe (RSS)