Chart-0.13.1: 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 coordinates.

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 numbers 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 a Source

Constructors

LinearAxisParams 

Fields

la_labelf_ :: a -> 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 a Source

Constructors

LogAxisParams 

Fields

loga_labelf_ :: a -> 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.

newtype PlotIndex Source

Type for capturing values plotted by index number (ie position in a list) rather than a numerical value.

Constructors

PlotIndex 

Fields

plotindex_i :: Int
 

type AxisFn x = [x] -> AxisData xSource

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

autoScaledAxis :: RealFloat a => LinearAxisParams a -> AxisFn aSource

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 :: RealFloat a => LogAxisParams a -> AxisFn aSource

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 axis. 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 be aligned to its 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.

autoIndexAxis :: Integral i => [String] -> [i] -> AxisData iSource

Create an axis for values indexed by position. The list of strings are the labels to be used.

addIndexes :: [a] -> [(PlotIndex, a)]Source

Augment a list of values with index numbers for plotting.

autoSteps :: Int -> [Double] -> [Double]Source

Given a target number of values, and a list of input points, find evenly spaced values from the set {1*X, 2*X, 2.5*X, 5*X} (where X is some power of ten) that evenly cover the input points.

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

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

vmap :: PlotValue x => (x, x) -> Range -> x -> DoubleSource

A linear mapping of points in one range to another.

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

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

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

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

la_labelf :: forall a[afL3]. T (LinearAxisParams a[afL3]) (a[afL3] -> String)Source

la_nLabels :: forall a[afL3]. T (LinearAxisParams a[afL3]) IntSource

la_nTicks :: forall a[afL3]. T (LinearAxisParams a[afL3]) IntSource

loga_labelf :: forall a[afL2]. T (LogAxisParams a[afL2]) (a[afL2] -> String)Source