Gruff Update With Bar Graphs 17 comments

posted Wednesday, October 26, 2005 by glyph

I showed off Gruff at the world’s most awesome Ruby group last night and stayed late to add initial bar graph support. Bar graphs don’t have lower labels yet, and I want to space the bar groups separately with a little bit of room in between.

Also fixed:

  • “require ‘rmagick’” is now titlecased for Windows
  • to_blob() should work now (thanks to Carlos Villela)
  • The gem does not include the rendered test graphs, which reduces it from 1 MB to 12 KB

Update with

gem install gruff

To use a bar graph, start your script with

graph = Gruff::Bar.new

Justin Palmer suggested custom graphics for the actual bars in the graphs. This would be awesome and is very possible. I want to implement pie graphs first and will then look at using more custom graphics in the charts themselves.

I’ll be putting Gruff on hold for the next week, but feel free to send me patches or enhancements.

This might also be a good time to mention that I am a full time freelance Ruby and Rails consultant. I’m booked at least through Christmas, but contact me if you need custom graphics programming, database design, or general Rails work!

17 comments

Leave a response

  • Hm… World’s most awesome Ruby Group? I smell a battle brewing.

    http://www.flickr.com/photos/mattpelletier/sets/1218232/

  • It’s not only Windows that requires the title case for RMagick, I couldn’t get my Ubuntu Linux to work until I changed the require.

    Fantastic libary by the way, I’ve been on the look out for a good looking graphing library and this seems to be it! :)

  • topfunky

    Correction:

    It tries “require ‘rmagick’” and then catches failure and tries “require ‘RMagick’” (on any platform).

    Hopefully this will fix it for most people.

  • Tom

    Huh!

    I was just writing the bar graph on the train. Now I’ll have to have a go at another one.

  • topfunky

    Others are doing pie and area.

    If you want to do a standard-deviation type chart or another that strikes your fancy, go for it.

    Std Dev

  • Yay! Thanks, Geoffrey. I’ll look into adding other types of graphs if/when I have some time. This looks really nice… additional themability (like the custom images idea) would be awesome.

  • Tomas Jogin

    Oh this is going to rock so much! My customers are going to love this. Great idea about the custom bar graphics btw.

  • Tom Ayerst

    Still doesn’t quite work with Windows. I tried fixing the rescue (its a nameError ;-) ) but that still chucks out a load of non-terminal error messages.

    A cleaner (but hacky) fix is:

    begin require ‘Win32API’ require ‘RMagick’ # capitalized on Windows rescue LoadError require ‘rmagick’ # not on other oses end

    in base.rb

  • Tom Ayerst

    eeew! yucky formatting!

    begin

    require 'Win32API'
    require 'RMagick' # capitalized on Windows

    rescue LoadError

    require 'rmagick' # not on other oses

    end

  • I’ve been doing graphing recently with SVG::Graph and using RMagick to convert to PNG.

    My results aren’t quite as pretty as yours, but SVG::Graph is very easy to use: http://weather.bensinclair.com/

    That’s a development mode Rails app, and the graph data on there isn’t up to date. A work in progress!

  • Scott

    Great work so far, this project looks promising. The default font setting in base made things a little wonky until I added the proper environment variable, though. Maybe have a different default if that environment variable isnt found, or on Windows use SystemRoot\Fonts?

    Scott

  • Scott

    Doh, wasnt the default font setting, ‘twas an ID10T error…. Anyway, some ideas:

    Multiple series support Custom legends Custom title placement Custom aspect ratios

  • ElGato

    Another stuck charting lib: http://www.harderweb.de/harderware/index.php?l=en&p=mrplot/

  • This isn’t related to the above, but I didn’t see your email address. The current version of the Pluralizer is out of date. I discovered that Rails 0.14 changed pluralization when it suddenly learned the plural of ‘quiz’ wasn’t ‘quizs’.

  • topfunky

    Thanks…the pluralizer has been updated to Rails 0.14.2.

  • topfunky

    The pluralizer has now been updated to Rails 0.14.2.

  • Greg

    This looks awesome, anyone can post an example on how to use this in a rails app (on windows)?

Your Comment

Nuby on Rails

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

Manufactured with

Subscribe

Subscribe (RSS)