Chart-0.16: A library for generating 2D Charts and Plots

Safe Haskell | None

Graphics.Rendering.Chart.SparkLine

Contents

- SparkLine type
- Drawing options
- Size calculation
- Rendering function

Description

Created : 2008-02-26 Modified : 2011-02-11 Version : 0.2

Sparklines implementation in Haskell. Sparklines are mini graphs inspired by Edward Tufte.

The original implementation (by Hitesh Jasani) used the gd package as a backend renderer, and is still available at http:hackage.haskell.orgpackagehsparklines The present version uses Cairo as its renderer, and integrates with the Chart package, in the sense that Sparklines are just another kind of (ToRenderable a => a), so can be composed into grids etc.

     dp :: [Double]
     dp = [24,21,32.3,24,15,34,43,55,57,72,74,75,73,72,55,44]

     sparkLineToPNG "bar_spark.png" (SparkLine barSpark dp)

Synopsis

- 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 -> CRender (PickFn ())
- sparkLineToPNG :: FilePath -> SparkLine -> IO (PickFn ())
- sparkLineToPDF :: FilePath -> SparkLine -> IO ()

# SparkLine type

data SparkLine Source

A sparkline is a single sequence of data values, treated as y-values. The x-values are anonymous and implicit in the sequence.

Constructors

SparkLine |

Fields

sl_options :: SparkOptions
sl_data :: [Double]

Instances

ToRenderable SparkLine |

# Drawing options

data SparkOptions Source

Options to render the sparklines in different ways.

Constructors

SparkOptions |

Fields

so_smooth :: Bool

  smooth or bars

so_step :: Int

  step size

so_height :: Int

  graph height (pixels)

so_limits :: (Double, Double)

  data point limits

so_bgColor :: Colour Double

  background color

so_minColor :: Colour Double

  color of minimum datapoint

so_maxColor :: Colour Double

  color of maximum datapoint

so_lastColor :: Colour Double

  color of last datapoint

so_minMarker :: Bool

  display minimum marker

so_maxMarker :: Bool

  display maximum marker

so_lastMarker :: Bool

  display last marker

Instances

Show SparkOptions |

smoothSpark :: SparkOptions Source

Default options for a smooth sparkline.

barSpark :: SparkOptions Source

Default options for a barchart sparkline.

# Size calculation

sparkSize :: SparkLine -> (Int, Int)Source

# Rendering function

renderSparkLine :: SparkLine -> CRender (PickFn ())Source

Render a SparkLine to a drawing surface using cairo.

sparkLineToPNG :: FilePath -> SparkLine -> IO (PickFn ())Source

Generate a PNG for the sparkline, using its natural size.

sparkLineToPDF :: FilePath -> SparkLine -> IO ()Source

Generate a PDF for the sparkline, using its natural size.