a ruby sparkline showing variation
July 25, 2007
Back in May’s Carnival of the Agilists I referenced a post by Clarke Ching in which he suggests we can learn a lot about variation in a complex process by simply flipping coins. When I tried the simulation a few times with Excel I found, as expected, that heads and tails don’t always occur in equal measure. But that was a pain to do, so I’ve made it easier. Over on my website I’ve posted a page that runs the simulation and shows the results as a sparkline graph. Every time you refresh that page it re-runs the simulation, with different random tosses of the imaginary coin.
(Disclaimer: The image is an SVG. It works fine in Firefox, but if you use IE you may need to install some kind of viewer.)
The sparkline itself is an SVG image generated by a Ruby script. If there’s enough interest I’ll turn it into a proper Ruby library and perhaps even gemify it. What features would you like to see if / when I do that?







January 11, 2008 at 8:03 pm
There is a kind of sparklines gem here:
http://nubyonrails.com/pages/sparklines
I added a histogram (bar chart) function to that library, and colored bars that were above a given threshold (like the rest of the drawing styles do). I don’t think that code went into the reworked version, although I was told it would be.
Anyway, things I like:
1) diverse set of drawing styles
2) not too rails-y, or rails oriented; nice generic Ruby (yay!) library is great
3) SVG is fine, since there’s lots of convertered (RMagick works fine for people trying to get things done, counter-propaganda aside)
Nice sparkline though :)
January 14, 2008 at 9:52 am
Actually I tried all of the existing gems and libraries, both for sparklines and for SVG — and in the end I just wrote a bunch of code that spits out SVG as text. Maybe I should tidy it up and put it up on RAA sometime…