posted
Monday, November 14, 2005
by
glyph




New version of Gruff with Bar, Area, and Pie charts. You can also add your own color scheme and use an image as the background (see bar_test.rb for an example).
I also put together a permanent page for the project that will link to the documentation, examples, etc.
Other Fixes
- Legends are now centered for smaller-size graphs.
- Line markers are generally rounded to some kind of significant digits (thanks to Christian Winkler). A little more work needs to be done to make this perfect.
- Lines are scaled with the number of points. If you have a line graph with many points, the lines will be thinner. (Christian Winkler)
Patches and suggestions are appreciated. I’ll open up subversion for public reading so patching can be done more easily.
Leave a response
Great stuff Geoff! Generating such lovely graphs is going to be great for our latest application.
Hey Geoffrey. This is really nice! I updated my site (here’s an explanation) to use your new system, and ended up with some enlightening charts like this. The built in themes is a nice touch (though, where’s the 43things theme? :) )... and everything was very easy to figure out. One thing I think I might like to see in future versions is a way to set the max X and Y values on the graph, but that’s no biggie. Awesome work!
Getting a strange error with latest version of gruff here is example
require ‘rubygems’ require ‘gruff’
g = Gruff::Line.new(600) g.title = ‘Running Times’
g.theme_37signals
range = (1..101)
g.data(‘Constant’,range.collect { 1 } ) g.data(‘O(log n)’,range.collect { |x| Math::log(x) }) g.data(‘O(n)’,range.collect { |x| x}) g.data(‘O(n log n)’,range.collect { |x| x*Math::log(x) })
g.labels = { 10=> ‘n=10’,50 => ‘n=50’,100 => ‘n=100’ } g.write(“test1.png”) ruby gruff.rb ./gruff.rb:4: uninitialized constant Gruff (NameError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `ge m_original_require’ from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re quire’ from gruff.rb:2