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

Copyright(c) Hitesh Jasani, 2008, Malcolm Wallace 2011, Tim Docker 2014
Safe HaskellNone




Sparklines are mini graphs inspired by Edward Tufte; see and for more information.

The original implementation (by Hitesh Jasani) used the gd package as a backend renderer, and is still available at

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" 


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.



Drawing options

data SparkOptions Source

Options to render the sparklines in different ways.




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

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

Return the width and height of the SparkLine.

Rendering function

renderSparkLine :: SparkLine -> ChartBackend (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.