Chart-0.6: 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 :: Render RectSize

a Cairo action to calculate a minimum size,

render :: Rect -> Render ()

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 -> Render ()

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

plot_render_legend :: Rect -> Render ()

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 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

Constructors

HA_Top 
HA_Bottom 

Instances

data VAxis Source

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

filledCirclesSource

Arguments

:: Double

radius of circle

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

hollowCirclesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

exesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

plussesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

starsSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

filledPolygonSource

Arguments

:: Double

radius of circle

-> Int

Number of vertices

-> Bool

Is right-side-up?

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

hollowPolygonSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Int

Number of vertices

-> Bool

Is right-side-up?

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoPointStyle 

solidLineSource

Arguments

:: Double

width of line

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoLineStyle 

dashedLineSource

Arguments

:: Double

width of line

-> [Double]

the dash pattern in device coordinates

-> Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoLineStyle 

solidFillStyleSource

Arguments

:: Double

red component of colour

-> Double

green component of colour

-> Double

blue component of colour

-> CairoFillStyle 

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. 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. 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.

monthsAxis :: Axis -> AxisFnSource

An axis that plots dates, with ticks and labels corresponding to calendar months. The values to be plotted against this axis can be created with doubleFromClockTime

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 (Render ()) 

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 (Render ()) 

newtype CairoFontStyle Source

Abstract data type for a font.

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

Constructors

CairoFontStyle (Render ())