ericgj / elm-sparklines / Facet

Utilities for creating scales for multiple data series together (fixed) or separately (free). Used internally by Sparklines facet views, but may be useful generally.

Basic types


type Scaling
    = Fixed
    | Free

A declarative type for how to scale data series


type alias Scaling2d =
{ x : Scaling, y : Scaling }

A declarative type for how to scale x and y dimensions of data series


type Scale a
    = FixedScale a
    | FreeScales (List a)

Either a single fixed scale or a list of free scales. A result type.


type alias Scale2d x y =
{ x : Scale x, y : Scale y }

Either a single fixed scale or a list of free scales, for x and y dimensions. A result type.

Continuous scales

linearScale : (a -> Basics.Float) -> ( Basics.Float, Basics.Float ) -> List a -> Scale.ContinuousScale Basics.Float

Create a linear scale from a single arbitrary data series, given the accessor and the range.

fixedLinearScale : (a -> Basics.Float) -> ( Basics.Float, Basics.Float ) -> List (List a) -> Scale.ContinuousScale Basics.Float

Create a fixed linear scale from a list of arbitrary data series, given the accessor and the range. (The domain of fixed scales is from the minimum value of all the series to the maximum value of all the series.)

freeLinearScales : (a -> Basics.Float) -> ( Basics.Float, Basics.Float ) -> List (List a) -> List (Scale.ContinuousScale Basics.Float)

Create free linear scales from a list of arbitrary data series, given the accessor and the range. (The domain of free scales is the domain of each data series separately.)

timeScale : Time.Zone -> (a -> Time.Posix) -> ( Basics.Float, Basics.Float ) -> List a -> Scale.ContinuousScale Time.Posix

Create a continuous time scale from a single arbitrary data series, given the accessor and the range.

fixedTimeScale : Time.Zone -> (a -> Time.Posix) -> ( Basics.Float, Basics.Float ) -> List (List a) -> Scale.ContinuousScale Time.Posix

Create a fixed continuous time scale from a list of arbitrary data series, given the accessor and the range. (The domain of fixed scales is from the minimum value (time) of all the series to the maximum value of all the series.)

freeTimeScales : Time.Zone -> (a -> Time.Posix) -> ( Basics.Float, Basics.Float ) -> List (List a) -> List (Scale.ContinuousScale Time.Posix)

Create free continuous time scales from a list of arbitrary data series, given the accessor and the range. (The domain of free scales is the domain of each data series separately.)

Band scales

timeBandScale : Scale.BandConfig -> (a -> Time.Posix) -> ( Basics.Float, Basics.Float ) -> List a -> Scale.BandScale Time.Posix

Create a single time band scale from an arbitrary data series, given the BandScale configuration , accessor and the range.

Note that this function does not change the data in any way, so you should pre-aggregate data by time interval and deal with possible gaps in intervals. The Timeseries module has tools for doing this.

fixedTimeBandScale : Scale.BandConfig -> (a -> Time.Posix) -> ( Basics.Float, Basics.Float ) -> List (List a) -> Scale.BandScale Time.Posix

Create a fixed time band scale from a list of arbitrary data series, given the BandScale configuration , accessor and the range. (The domain of fixed time band scales is a list of times from the earliest in all the series to the latest in all the series.)

Note that this function does not change the data in any way, so you should pre-aggregate data by time interval and deal with possible gaps in intervals. The Timeseries module has tools for doing this.

freeTimeBandScales : Scale.BandConfig -> (a -> Time.Posix) -> ( Basics.Float, Basics.Float ) -> List (List a) -> List (Scale.BandScale Time.Posix)

Create free time band scales from a list of arbitrary data series, given the BandScale configuration , accessor and the range. (The domain of free time band scales is a list of times from the earliest to the latest, within each series separately.)

Note that this function does not change the data in any way, so you should pre-aggregate data by time interval and deal with possible gaps in intervals. The Timeseries module has tools for doing this.