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

Graphics.Rendering.Chart.Axis

Description

Code to calculate and render axes.

Note that template haskell is used to derive accessor functions (see Data.Accessor) for each field of the following data types:

These accessors are not shown in this API documentation. They have the same name as the field, but with the trailing underscore dropped. Hence for data field f_::F in type D, they have type

   f :: Data.Accessor.Accessor D F

Synopsis

Documentation

data AxisData x Source

The basic data associated with an axis showing values of type x

Constructors

AxisData 

Fields

axis_viewport_ :: Range -> x -> Double

The axis_viewport_ function maps values into device cordinates.

axis_ticks_ :: [(x, 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_ :: [(x, 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_ :: [x]

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

data AxisT x Source

Collect the information we need to render an axis. The bool is true if the axis direction is reversed

Instances

data LinearAxisParams Source

Constructors

LinearAxisParams 

Fields

la_labelf_ :: Double -> String

The function used to show the axes labels

la_nLabels_ :: Int

The target number of labels to be shown

la_nTicks_ :: Int

The target number of ticks to be shown

data LogAxisParams Source

Constructors

LogAxisParams 

Fields

loga_labelf_ :: LogValue -> String

The function used to show the axes labels

data AxisStyle Source

Control values for how an axis gets displayed

Constructors

AxisStyle 

Fields

axis_line_style_ :: CairoLineStyle
 
axis_label_style_ :: CairoFontStyle
 
axis_grid_style_ :: CairoLineStyle
 
axis_label_gap_ :: Double

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

type AxisFn x = [x] -> AxisData xSource

A function to generate the axis data given the data values to be plotted against it.

autoScaledAxis :: LinearAxisParams -> AxisFn DoubleSource

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 :: LogAxisParams -> AxisFn LogValueSource

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

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 LocalTimes for labels. The values to be plotted against this axis can be created with doubleFromLocalTime

autoTimeAxis :: AxisFn LocalTimeSource

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 doubleFromLocalTime

days :: TimeSeqSource

A TimeSeq for calendar days

months :: TimeSeqSource

A TimeSeq for calendar months

years :: TimeSeqSource

A TimeSeq for calendar years

axisOverhang :: Ord x => AxisT x -> CRender (Double, Double)Source

Calculate the amount by which the labels extend beyond the ends of the axis

axis_viewport :: forall x[afhq]. T (AxisData x[afhq]) (Range -> x[afhq] -> Double)Source

axis_ticks :: forall x[afhq]. T (AxisData x[afhq]) ([] ((,) x[afhq] Double))Source

axis_labels :: forall x[afhq]. T (AxisData x[afhq]) ([] ((,) x[afhq] String))Source

axis_grid :: forall x[afhq]. T (AxisData x[afhq]) ([] x[afhq])Source