Sparklines are now available as a gem, and as a Rails generator! There is also a RubyForge Project.

In order to not conflict with the existing Nitro Spark Ruby project, the name has been changed to ’Sparklines.’ So if you have tried it out in the last few days, change your code to reference ”sparklines” instead of ”spark.” The helper tag has also been changed to the singular sparkline_tag.
Also, there is a new :line_color option so you can set the color of the smooth graph’s line. Thanks to all those who offered suggestions.
At any rate, download the newest version!
To install:
sudo gem install sparklines sudo gem install sparklines_generator
Or download here for manual installation:
If you’re using Rails, you only have three more steps to get going:
Note: You can still copy ‘sparklines.rb’ to your app’s ‘lib’ directory if you are working on a server without root access.
After installing both gems, you can run the Rails generator to copy the Sparkline controller and helper files.
ruby script/generate sparklines
Open up config/environment.rb and add the following line to the bottom of the file:
require 'sparklines'
Now, open a controller where you would like to use sparklines. Add the helper:
class SpecialReportController < ApplicationController helper :sparklines end
Now you are in business! Go nuts in any of those controllers’ views!
<%= sparkline_tag [10,20,30], :type => 'pie' %>
No function sparklines_tag The helper function has been changed to the singular “sparkline_tag” instead of the plural. If you downloaded it during the 15 minutes that the plural version was up, just update your gem (‘gem install sparklines_generator’) and re-generate the files in your rails app (‘rails script/server generate sparklines’).
RMagick gem isn’t found If you installed RMagick separately of the gem system, you might have to reinstall. I just re-installed with “gem install rmagick” and it worked fine. If not, try editing your Magick-config file (mine was in /usr/local/bin) to remove the -lcms and/or -ltiff flags.
RMagick is installed, but graphs won’t show up If your server was running before you installed the gems, you might have to restart WEBrick or your FCGI processes.
Enjoy!
I’ve been running gruff for a while… I love it.
So, today, I thought I’d give sparklines a try. Here’s the error that I got when either trying to run the generate script, or starting up WEBrick:
can’t activate rubyforge (= 0.4.5)
What’s up with that? There doesn’t seem to be copies of it available using gem. Why is it needed anyway? I couldn’t see any mention of it in the sparklines code, so it looks like something deep happening…
Well, I managed to get it to work, but it’s a bit of a kludge.
For some reason, rubyforge 0.4.5 was already in gem, but it was complaining about it for some reason.
My workaround was to copy the 0.4.5 gem, and copy the contents of rubyforge 1.0 into the 0.4.5 folder. Dodgey, I know, but it works.
I’m just hoping I don’t have to do something like this when I deploy it onto my Solaris server. This problem arose under Mac OSX, btw.
That’s an odd error, and may have to do with the dependency on the Hoe gem.