I've put the first release of hsparklines up on Hackage. It's a sparklines library implemented in Haskell. I know there are a number of web service based solutions that one could use for this, but for those who've used web services, you know that there are some things you want to keep local.
If you haven't played with sparklines yet, you should. They're minigraphs inspired by Edward Tufte to present a large amount of contextual information in a minimum of space. For example, here's a sparkline that shows the number of uploads to Hackage by month. It hardly takes up any space, yet quickly communicates how well the Haskell community is growing and contributing a good amount of code.
Download the tarball from Hackage and extract it into a directory. Go into the directory and run configure, build, haddock (optional) and install.
% tar zxvf hsparklines-0.1.0.tar.gz % cd hsparklines-0.1.0 % runhaskell Setup.lhs configure % runhaskell Setup.lhs build % runhaskell Setup.lhs haddock -- optional step if you want local docs % sudo runhaskell Setup.lhs install
First of all you're going to need some data. We'll assume you acquired some from whatever means necessary. With the first release, we can generate smooth sparklines and bar sparklines using the following code as an example. See the examples directory in the distribution for more examples.
import Graphics.Rendering.HSparklines dp :: [Float] dp = [13.4, ... ] main :: IO () main = make smoothSpark dp >>= savePngFile "dummy.png"
You can also generate a base64 encoding of the image to use in a data uri.
make smoothSpark dp >>= encodePngAsDataUrl >>= putStrLn
- hsparklines 0.1.0 docs online
- Edward Tufte on sparklines
- Joe Gregario's sparklines webservice
- Geoffrey Grosenbach's sparklines for Ruby
- Sparkline generator using Google Charts
Very Cool! I like this!
This is incredibly useful for me. Thanks for the hackage upload!
Tags: haskell, hsparklines, projects