Copyright | (c) Hitesh Jasani, 2008, Malcolm Wallace 2011, Tim Docker 2014 |
---|---|
License | BSD3 |
Safe Haskell | None |
Language | Haskell98 |
Sparklines are mini graphs inspired by Edward Tufte; see http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR and http://en.wikipedia.org/wiki/Sparkline for more information.
The original implementation (by Hitesh Jasani) used the gd package as a backend renderer, and is still available at http://hackage.haskell.org/package/hsparklines.
The present version integrates with
the Chart package, in the sense that Sparklines are just another
kind of (ToRenderable a => a
), so they can be composed into grids
and used with the rest of Chart.
dp :: [Double] dp = [24,21,32.3,24,15,34,43,55,57,72,74,75,73,72,55,44] sl = SparkLine barSpark dp fopts = FileOptions (sparkSize sl) PNG renderableToFile fopts (sparkLineToRenderable sl) "bar_spark.png"
- data SparkLine = SparkLine {
- sl_options :: SparkOptions
- sl_data :: [Double]
- data SparkOptions = SparkOptions {
- so_smooth :: Bool
- so_step :: Int
- so_height :: Int
- so_limits :: (Double, Double)
- so_bgColor :: Colour Double
- so_minColor :: Colour Double
- so_maxColor :: Colour Double
- so_lastColor :: Colour Double
- so_minMarker :: Bool
- so_maxMarker :: Bool
- so_lastMarker :: Bool
- smoothSpark :: SparkOptions
- barSpark :: SparkOptions
- sparkSize :: SparkLine -> (Int, Int)
- renderSparkLine :: SparkLine -> BackendProgram (PickFn ())
- sparkLineToRenderable :: SparkLine -> Renderable ()
- sparkWidth :: SparkLine -> Int
SparkLine type
A sparkline is a single sequence of data values, treated as y-values. The x-values are anonymous and implicit in the sequence.
SparkLine | |
|
Drawing options
data SparkOptions Source #
Options to render the sparklines in different ways.
SparkOptions | |
|
smoothSpark :: SparkOptions Source #
Default options for a smooth sparkline.
barSpark :: SparkOptions Source #
Default options for a barchart sparkline.
Size calculation
Rendering function
renderSparkLine :: SparkLine -> BackendProgram (PickFn ()) Source #
Render a SparkLine to a drawing surface.
sparkLineToRenderable :: SparkLine -> Renderable () Source #
Create a renderable from a SparkLine.
sparkWidth :: SparkLine -> Int Source #
Compute the width of a SparkLine, for rendering purposes.