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

Safe HaskellNone

Graphics.Rendering.Chart

Description

A framework for creating 2D charts in Haskell.

The basic model is that you define a value of type Renderable, typically by applying toRenderable to some other value. This Renderable is then actually displayed or output by calling either renderableToPNGFile, or renderableToWindow.

Currently, the only useful Renderable for displaying charts is created by applying toRenderable to a value of type Layout1

For a simpler though less flexible API, see Graphics.Rendering.Chart.Simple.

Synopsis

Documentation

data Renderable Source

A Renderable is a record of functions required to layout a graphic element.

Constructors

Renderable 

Fields

minsize :: CRender RectSize

a Cairo action to calculate a minimum size,

render :: Rect -> CRender ()

a Cairo action for drawing it within a specified rectangle.

class ToRenderable a whereSource

A type class abtracting the conversion of a value to a Renderable.

data Layout1 Source

A Layout1 value is a single plot area, with optional: axes on each of the 4 sides; title at the top; legend at the bottom.

data Axis Source

The concrete data type for an axis

Constructors

Axis 

Fields

axis_viewport :: Range -> Double -> Double

The axis_viewport function maps values into device cordinates.

axis_title :: String

The title string to be displayed on the axis. An empty string means no title.

axis_ticks :: [(Double, Double)]

The tick marks on the axis as pairs. The first element is the position on the axis (in viewport units) and the second element is the length of the tick in output coordinates. The tick starts on the axis, and positive number are drawn towards the plot area.

axis_labels :: [(Double, String)]

The labels on an axis as pairs. The first element is the position on the axis (in viewport units) and the second is the label text string.

axis_grid :: [Double]

The positions on the axis (in viewport units) where we want to show grid lines.

axis_label_gap :: Double

How far the labels are to be drawn from the axis.

axis_title_style :: CairoFontStyle
 
axis_line_style :: CairoLineStyle
 
axis_label_style :: CairoFontStyle
 
axis_grid_style :: CairoLineStyle
 

data Plot Source

Interface to control plotting on a 2D area.

Constructors

Plot 

Fields

plot_render :: PointMapFn -> CRender ()

Given the mapping between model space coordinates and device coordinates, render this plot into a chart.

plot_render_legend :: Rect -> CRender ()

Render a small sample of this plot into the given rectangle. This is for used to generate a the legend a chart.

plot_all_points :: [Point]

All of the model space coordinates to be plotted. These are used to autoscale the axes where necessary.

class ToPlot a whereSource

a type class abstracting the conversion of a value to a Plot.

Methods

toPlot :: a -> PlotSource

data PlotPoints Source

Value defining a series of datapoints, and a style in which to render them

Instances

data PlotErrBars Source

Value defining a series of error intervals, and a style in which to render them

Instances

data PlotLines Source

Value defining a series of (possibly disjointed) lines, and a style in which to render them

Instances

data PlotFillBetween Source

Value specifying a plot filling the area between two sets of Y coordinates, given common X coordinates.

data HAxis Source

The side of an horizontal axis

Constructors

HA_Top 
HA_Bottom 

Instances

data VAxis Source

The side of a vertical axis

Constructors

VA_Left 
VA_Right 

Instances

data Rect Source

A rectangle is defined by two points

Constructors

Rect Point Point 

Instances

data Point Source

A point in two dimensions

Constructors

Point 

Fields

p_x :: Double
 
p_y :: Double
 

Instances

data Color Source

Constructors

Color 

Fields

c_r :: Double
 
c_g :: Double
 
c_b :: Double
 

data ErrPoint Source

Value for holding a point with associated error bounds for each axis.

Constructors

ErrPoint 

Fields

ep_x :: Double
 
ep_y :: Double
 
ep_dx :: Double
 
ep_dy :: Double
 

Instances

filledCirclesSource

Arguments

:: Double

radius of circle

-> Color

colour

-> CairoPointStyle 

hollowCirclesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

exesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

plussesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

starsSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

filledPolygonSource

Arguments

:: Double

radius of circle

-> Int

Number of vertices

-> Bool

Is right-side-up?

-> Color 
-> CairoPointStyle 

hollowPolygonSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Int

Number of vertices

-> Bool

Is right-side-up?

-> Color 
-> CairoPointStyle 

solidLineSource

Arguments

:: Double

width of line

-> Color 
-> CairoLineStyle 

dashedLineSource

Arguments

:: Double

width of line

-> [Double]

the dash pattern in device coordinates

-> Color 
-> CairoLineStyle 

fontStyleSource

Arguments

:: String

the font name

-> Double

the font size

-> FontSlant

the font slant

-> FontWeight

the font weight

-> CairoFontStyle 

independentAxes :: AxisFn -> AxisFn -> AxesFnSource

Show independent axes on each side of the layout

linkedAxes :: AxisFn -> AxesFnSource

Show the same axis on both sides of the layout

linkedAxes' :: AxisFn -> AxesFnSource

Show the same axis on both sides of the layout, but with labels only on the primary side

explicitAxis :: Maybe Axis -> AxisFnSource

Explicitly specify an axis

autoScaledAxis :: Axis -> AxisFnSource

Generate a linear axis automatically. Same as autoScaledAxis', but with labels generated with showD (showD is show for doubles, but with any trailing .0 removed)

autoScaledAxis' :: (Double -> String) -> Axis -> AxisFnSource

Generate a linear axis automatically. The supplied axis is used as a template, with the viewport, ticks, labels and grid set appropriately for the data displayed against that axies. The resulting axis will only show a grid if the template has some grid values.

autoScaledLogAxis :: Axis -> AxisFnSource

Generate a log axis automatically. Same as autoScaledLogAxis', but with labels generated with showD (showD is show for doubles, but with any trailing .0 removed)

autoScaledLogAxis' :: (Double -> String) -> Axis -> AxisFnSource

Generate a log axis automatically. The supplied axis is used as a template, with the viewport, ticks, labels and grid set appropriately for the data displayed against that axies. The resulting axis will only show a grid if the template has some grid values.

timeAxis :: TimeSeq -> TimeSeq -> TimeLabelFn -> Axis -> AxisFnSource

Create an AxisFn to for a time axis. The first TimeSeq sets the minor ticks, and the ultimate range will aligned to it's elements. The second TimeSeq sets the labels and grid. The TimeLabelFn is used to format clocktimes for labels. The values to be plotted against this axis can be created with doubleFromClockTime

autoTimeAxis :: Axis -> AxisFnSource

Automatically choose a suitable time axis, based upon the time range of data. The values to be plotted against this axis can be created with doubleFromClockTime

formatTime :: String -> TimeLabelFnSource

Use an strftime() formatted string to display a time

days :: TimeSeqSource

A TimeSeq for calendar days

months :: TimeSeqSource

A TimeSeq for calendar months

years :: TimeSeqSource

A TimeSeq for calendar years

renderableToPNGFile :: Renderable -> Int -> Int -> FilePath -> IO ()Source

Output the given renderable to a PNG file of the specifed size (in pixels), to the specified file.

renderableToPDFFile :: Renderable -> Int -> Int -> FilePath -> IO ()Source

Output the given renderable to a PDF file of the specifed size (in points), to the specified file.

renderableToPSFile :: Renderable -> Int -> Int -> FilePath -> IO ()Source

Output the given renderable to a postscript file of the specifed size (in points), to the specified file.

doubleFromClockTime :: ClockTime -> DoubleSource

Map a clocktime value to a plot cordinate

clockTimeFromDouble :: Double -> ClockTimeSource

Map a plot cordinate to a clocktime

newtype CairoLineStyle Source

Abstract data type for the style of a line

The contained Cairo action sets the required line in the Cairo rendering state.

Constructors

CairoLineStyle (CRender ()) 

newtype CairoFillStyle Source

Abstract data type for a fill style

The contained Cairo action sets the required fill style in the Cairo rendering state.

Constructors

CairoFillStyle (CRender ()) 

newtype CairoFontStyle Source

Abstract data type for a font.

The contained Cairo action sets the required font in the Cairo rendering state.

Constructors

CairoFontStyle (CRender ())