Graphics.Rendering.Chart.Axis.Time

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

Copyright | (c) Tim Docker 2010 2014
License | BSD-style (see chart/COPYRIGHT)
Safe Haskell | None
Language | Haskell98

Graphics.Rendering.Chart.Axis.Time

Contents

- Orphan instances

Description

Calculate and render time axes

Synopsis

- type TimeSeq = UTCTime -> ([UTCTime], [UTCTime])
- type TimeLabelFn = UTCTime -> String
- data TimeLabelAlignment
  - = UnderTicks
  - | BetweenTicks
- class TimeValue t where
  - utctimeFromTV :: t -> UTCTime
  - tvFromUTCTime :: UTCTime -> t
  - doubleFromTimeValue :: t -> Double
  - timeValueFromDouble :: Double -> t
- timeValueAxis :: TimeValue t => TimeSeq -> TimeSeq -> TimeLabelFn -> TimeLabelAlignment -> TimeSeq -> TimeLabelFn -> TimeLabelAlignment -> AxisFn t
- autoTimeValueAxis :: TimeValue t => AxisFn t
- days :: TimeSeq
- months :: TimeSeq
- years :: TimeSeq

# Documentation

type TimeSeq = UTCTime -> ([UTCTime], [UTCTime]) #

TimeSeq is a (potentially infinite) set of times. When passed a reference time, the function returns a a pair of lists. The first contains all times in the set less than the reference time in decreasing order. The second contains all times in the set greater than or equal to the reference time, in increasing order.

type TimeLabelFn = UTCTime -> String #

How to display a time

data TimeLabelAlignment #

Constructors

UnderTicks |
BetweenTicks |

#### Instances

Instances details

Show TimeLabelAlignment # |
Instance details Defined in Graphics.Rendering.Chart.Axis.Time Methods showsPrec :: Int -> TimeLabelAlignment -> ShowS # show :: TimeLabelAlignment -> String # showList :: [TimeLabelAlignment] -> ShowS #

class TimeValue t where #

A typeclass abstracting the functions we need to be able to plot against an axis of time type `d`.

Minimal complete definition

utctimeFromTV, tvFromUTCTime

Methods

utctimeFromTV :: t -> UTCTime #

tvFromUTCTime :: UTCTime -> t #

doubleFromTimeValue :: t -> Double #

timeValueFromDouble :: Double -> t #

#### Instances

Instances details

TimeValue Day # |
Instance details Defined in Graphics.Rendering.Chart.Axis.Time Methods utctimeFromTV :: Day -> UTCTime # tvFromUTCTime :: UTCTime -> Day # doubleFromTimeValue :: Day -> Double # timeValueFromDouble :: Double -> Day #
TimeValue UTCTime # |
Instance details Defined in Graphics.Rendering.Chart.Axis.Time Methods utctimeFromTV :: UTCTime -> UTCTime # tvFromUTCTime :: UTCTime -> UTCTime # doubleFromTimeValue :: UTCTime -> Double # timeValueFromDouble :: Double -> UTCTime #
TimeValue LocalTime # |
Instance details Defined in Graphics.Rendering.Chart.Axis.Time Methods utctimeFromTV :: LocalTime -> UTCTime # tvFromUTCTime :: UTCTime -> LocalTime # doubleFromTimeValue :: LocalTime -> Double # timeValueFromDouble :: Double -> LocalTime #

timeValueAxis #

Arguments

:: TimeValue t |
=> TimeSeq | Set the minor ticks, and the final range will be aligned to its elements.
-> TimeSeq | Set the labels and grid.
-> TimeLabelFn |
-> TimeLabelAlignment |
-> TimeSeq | Set the second line of labels.
-> TimeLabelFn | Format `t` for labels.
-> TimeLabelAlignment |
-> AxisFn t |

Create an `AxisFn` to for a time axis.

The values to be plotted against this axis can be created with `doubleFromLocalTime`.

Implementation detail: `PlotValue` constraint is needed to use `vmap`.

autoTimeValueAxis :: TimeValue t => AxisFn t #

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

days :: TimeSeq #

A `TimeSeq` for calendar days.

months :: TimeSeq #

A `TimeSeq` for calendar months.

years :: TimeSeq #

A `TimeSeq` for calendar years.

# Orphan instances

PlotValue Day # |
Instance details Methods toValue :: Day -> Double # fromValue :: Double -> Day # autoAxis :: AxisFn Day #
PlotValue UTCTime # |
Instance details Methods toValue :: UTCTime -> Double # fromValue :: Double -> UTCTime # autoAxis :: AxisFn UTCTime #
PlotValue LocalTime # |
Instance details Methods toValue :: LocalTime -> Double # fromValue :: Double -> LocalTime # autoAxis :: AxisFn LocalTime #