Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of the script.aculo.us user interface JavaScript library, a member of the Prototype core team and a Ruby on Rails core alumnus. You're using my work every day, even if you're not aware of it (sounds creepy, I know!). Need JS foo? Hire me.

Pure Ruby Sparklines

September 17th, 2005 by Thomas Fuchs, Comments Off

Update October 5, 2009: This is some REALLY old code, but I managed to salvage it recently and put it on Github at http://github.com/madrobby/spark_pr. Please download the code from there!

In Weed, we use Sparklines for displaying web site stats. But, you have to go through the rather tedious process (depending on your setup) of installing RMagick to generate them.

To get rid of the RMagick dependency, I came up with a pure ruby solution, based on why’s excellent Bumpspark and on Geoffrey’s hip gem. The solution currently supports the “smooth” type Sparklines, but i’ll eventually hope to add all types that Geoffrey’s gem supports.

So, you can now have nice “smooth-style” sparklines, just one ruby file required:

Pure Ruby sparkline example

Drawing is done with alpha-blending and antialiased lines.

Grab the source at the Weed collaboa (and consider it beta quality only!).

Update: It now supports ASCII output too, for the GUI challenged:


                                                +++++
                                                +++++
                                                ++#++         +                       +--
                                                ++#++        ---                     -- --+
                                                +++#+        - -                     +
                                      +          + -        +   +     +-             -
                                    -- -         +  -      -     -  -- -+-          -
                              +--  --   -       --  -      -     - --    -+         -
                            --  --+     -       -    -    +       +        --      -
  +++++       +            --            -      +    +  --                  --     +
       --   -- +         -+               +     -    ----                     +-- --
        -- --   +      -+-                 -   --     +                         --+
          +      +  --+-                   -   +
                  +--                       +  +

                                              -

Post to Twitter Tweet This Post Post to Digg Digg This Post Post to Facebook Share on Facebook

Comments Off

JavaScript Rocks! Peformance ebook
Do you run a web site or web application? Do your users a favor, and grab our ebook on JavaScript performance. Profit from our knowledge gathered in over 15 years of working with the Web and JavaScript and make your sites ultra-fast and your users ultra-happy.

Comments are closed.