| Copyright | (c) Jann Müller 2018 |
|---|---|
| License | MIT |
| Maintainer | Jann Müller <j.mueller.11@alumni.ucl.ac.uk> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.H3.Scales
Description
A set of useful scales for visualising data. Each scale is identified by an
empty data type (Continuous, Ordinal etc). To use a scale f to map
as to bs you need to construct a value of ScaleOptions f a b. To
make this easier, a constructor such as continuous, ordinal, etc. is
provided for each scale.
Scales can be combined in a number of ways, just like to ordinary functions.
For example, we can take the Product of any two scales f and g.
The ScaleOptions of combined scales are usually functions of the
ScaleOptions of their components, and can be constructed in the same way.
Synopsis
- arrow :: (a -> b) -> ScaleOptions ((->) a) a b
- continuous :: Extent a -> IncludeZeroPolicy -> ScaleOptions Continuous a a
- data Continuous a
- data IncludeZeroPolicy
- cardinal :: Extent a -> ScaleOptions Cardinal a Double
- data Cardinal a
- ordinal :: NonEmpty a -> (a -> String) -> ScaleOptions Ordinal a Double
- data Ordinal a
- product :: ScaleOptions f a b -> ScaleOptions g c d -> ScaleOptions (Product f g) (a, c) (b, d)
- newtype Product f g a = Product {
- getProduct :: (f (LeftV a), g (RightV a))
- nested :: ScaleOptions f a b -> ScaleOptions g c b -> ScaleOptions (Nested f g) (a, c) b
- data Nested (f :: * -> *) (g :: * -> *) p
- transformed :: (Target f b -> Target f b) -> ScaleOptions f a b -> ScaleOptions (Transformed f) a b
- data Transformed (f :: * -> *) a
- anchored :: a -> ScaleOptions f a b -> ScaleOptions (Anchored f) a b
- data Anchored (f :: * -> *) a
- split :: ScaleOptions f a b -> ScaleOptions g a c -> ScaleOptions (Split f g) a (b, c)
- data Split (f :: * -> *) (g :: * -> *) a
- newtype Pair a = Pair {
- getPair :: (a, a)
- class ProductV p
- data family ScaleOptions f a b :: *
Basic scales
arrow :: (a -> b) -> ScaleOptions ((->) a) a b Source #
Every function 'f :: a -> b' is a scale
Arguments
| :: Extent a | The source range |
| -> IncludeZeroPolicy | Whether to extend the source range to include 0 |
| -> ScaleOptions Continuous a a |
Create a continuous scale (map between real numbers).
data Continuous a Source #
Instances
| (Ord a, RealFrac a, Floating a) => Scalable Continuous a a Source # | |
Defined in Data.H3.Scales Associated Types type Target Continuous :: * -> * Source # type TargetRange Continuous a :: * Source # data ScaleOptions Continuous a a :: * Source # Methods scale :: ScaleOptions Continuous a a -> TargetRange Continuous a -> a -> Target Continuous a Source # | |
| (Ord a, RealFrac a, Floating a) => ChartVisuals (Vis (ScaleOptions Continuous a a)) (Extent a) a Source # | |
Defined in Data.H3.Visuals Methods visuals :: Vis (ScaleOptions Continuous a a) -> Extent a -> VisualElements String a Source # | |
| type Target Continuous Source # | |
Defined in Data.H3.Scales | |
| type TargetRange Continuous a Source # | |
Defined in Data.H3.Scales | |
| data ScaleOptions Continuous a a Source # | |
Defined in Data.H3.Scales | |
data IncludeZeroPolicy Source #
Indicates whether to extend the source (domain) of a continuous scale to include 0.
Extending the scale to 0 ensures that absolute values are comparable but may obscure differences between values if the variation of the data is small compared to its absolute size.
Constructors
| IncludeZero | |
| DontIncludeZero |
cardinal :: Extent a -> ScaleOptions Cardinal a Double Source #
Create a cardinal scale (map from integers to Double).
Instances
| (Ord a, Integral a) => Scalable Cardinal a Double Source # | |
| (Ord a, Integral a) => ChartVisuals (Vis (ScaleOptions Cardinal a Double)) (Extent Double) Double Source # | |
Defined in Data.H3.Visuals | |
| type Target Cardinal Source # | |
Defined in Data.H3.Scales | |
| type TargetRange Cardinal Double Source # | |
Defined in Data.H3.Scales | |
| data ScaleOptions Cardinal a Double Source # | |
Defined in Data.H3.Scales | |
Arguments
| :: NonEmpty a | The domain |
| -> (a -> String) | A description of the values (for creating labels) |
| -> ScaleOptions Ordinal a Double |
Create an ordinal scale (map from some type with an Ord instance to
'Extent Double').
Instances
| (Ord a, Eq a) => Scalable Ordinal a Double Source # | |
| (Ord a, Eq a) => ChartVisuals (Vis (ScaleOptions Ordinal a Double)) (Extent Double) Double Source # | |
Defined in Data.H3.Visuals | |
| type Target Ordinal Source # | |
Defined in Data.H3.Scales | |
| type TargetRange Ordinal Double Source # | |
Defined in Data.H3.Scales | |
| data ScaleOptions Ordinal a Double Source # | |
Defined in Data.H3.Scales | |
Combinators
product :: ScaleOptions f a b -> ScaleOptions g c d -> ScaleOptions (Product f g) (a, c) (b, d) Source #
The product of two scales.
newtype Product f g a Source #
Constructors
| Product | |
Fields
| |
Instances
| (Scalable f a b, Scalable g c d) => Scalable (Product f g) (a, c) (b, d) Source # | |
Defined in Data.H3.Scales Associated Types type Target (Product f g) :: * -> * Source # type TargetRange (Product f g) (b, d) :: * Source # data ScaleOptions (Product f g) (a, c) (b, d) :: * Source # Methods scale :: ScaleOptions (Product f g) (a, c) (b, d) -> TargetRange (Product f g) (b, d) -> (a, c) -> Target (Product f g) (b, d) Source # | |
| type Target (Product f g) Source # | |
| type TargetRange (Product f g) (b, d) Source # | |
Defined in Data.H3.Scales | |
| data ScaleOptions (Product f g) (a, c) (b, d) Source # | |
Defined in Data.H3.Scales data ScaleOptions (Product f g) (a, c) (b, d) = ProdScaleOpts (ScaleOptions f a b) (ScaleOptions g c d) | |
nested :: ScaleOptions f a b -> ScaleOptions g c b -> ScaleOptions (Nested f g) (a, c) b Source #
nested takes two scales g and f and creates a g scale within each
f result. This requires 'Target f', Target g and TargetRange g to be
identical.
data Nested (f :: * -> *) (g :: * -> *) p Source #
Instances
| (h ~ TargetRange g b, ChartVisuals (Vis (ScaleOptions f a b)) h b) => ChartVisuals (Vis (ScaleOptions (Nested f g) (a, c) b)) h b Source # | |
Defined in Data.H3.Visuals Methods visuals :: Vis (ScaleOptions (Nested f g) (a, c) b) -> h -> VisualElements String b Source # | |
| (Target g b ~ TargetRange g b, Target f b ~ TargetRange g b, Scalable f a b, Scalable g c b) => Scalable (Nested f g) (a, c) b Source # | |
Defined in Data.H3.Scales Associated Types type Target (Nested f g) :: * -> * Source # type TargetRange (Nested f g) b :: * Source # data ScaleOptions (Nested f g) (a, c) b :: * Source # Methods scale :: ScaleOptions (Nested f g) (a, c) b -> TargetRange (Nested f g) b -> (a, c) -> Target (Nested f g) b Source # | |
| type Target (Nested f g) Source # | |
Defined in Data.H3.Scales | |
| type TargetRange (Nested f g) b Source # | |
Defined in Data.H3.Scales | |
| data ScaleOptions (Nested f g) (a, c) b Source # | |
Defined in Data.H3.Scales | |
transformed :: (Target f b -> Target f b) -> ScaleOptions f a b -> ScaleOptions (Transformed f) a b Source #
Map the results of a scale monomorphically.
data Transformed (f :: * -> *) a Source #
Instances
| (Target f b ~ h b, Functor h, Scalable f a b) => Scalable (Transformed f) a b Source # | |
Defined in Data.H3.Scales Associated Types type Target (Transformed f) :: * -> * Source # type TargetRange (Transformed f) b :: * Source # data ScaleOptions (Transformed f) a b :: * Source # Methods scale :: ScaleOptions (Transformed f) a b -> TargetRange (Transformed f) b -> a -> Target (Transformed f) b Source # | |
| (h ~ TargetRange f b, ChartVisuals (Vis (ScaleOptions f a b)) h b) => ChartVisuals (Vis (ScaleOptions (Transformed f) a b)) h b Source # | |
Defined in Data.H3.Visuals Methods visuals :: Vis (ScaleOptions (Transformed f) a b) -> h -> VisualElements String b Source # | |
| type Target (Transformed f) Source # | |
Defined in Data.H3.Scales | |
| data ScaleOptions (Transformed f) a b Source # | |
Defined in Data.H3.Scales data ScaleOptions (Transformed f) a b = TransformedOpts (Target f b -> Target f b) (ScaleOptions f a b) | |
| type TargetRange (Transformed f) b Source # | |
Defined in Data.H3.Scales | |
anchored :: a -> ScaleOptions f a b -> ScaleOptions (Anchored f) a b Source #
Extend a scale by "anchoring" its results to a fixed point of the domain
data Anchored (f :: * -> *) a Source #
Instances
| (Applicative (Target f), Scalable f a b) => Scalable (Anchored f) a b Source # | |
| (h ~ TargetRange f b, ChartVisuals (Vis (ScaleOptions f a b)) h b) => ChartVisuals (Vis (ScaleOptions (Anchored f) a b)) h b Source # | |
Defined in Data.H3.Visuals Methods visuals :: Vis (ScaleOptions (Anchored f) a b) -> h -> VisualElements String b Source # | |
| type Target (Anchored f) Source # | |
| data ScaleOptions (Anchored f) a b Source # | |
Defined in Data.H3.Scales | |
| type TargetRange (Anchored f) b Source # | |
Defined in Data.H3.Scales | |
split :: ScaleOptions f a b -> ScaleOptions g a c -> ScaleOptions (Split f g) a (b, c) Source #
Apply two scales to the same value
data Split (f :: * -> *) (g :: * -> *) a Source #
Instances
| (Scalable f a b, Scalable g a c) => Scalable (Split f g) a (b, c) Source # | |
Defined in Data.H3.Scales Associated Types type Target (Split f g) :: * -> * Source # type TargetRange (Split f g) (b, c) :: * Source # data ScaleOptions (Split f g) a (b, c) :: * Source # Methods scale :: ScaleOptions (Split f g) a (b, c) -> TargetRange (Split f g) (b, c) -> a -> Target (Split f g) (b, c) Source # | |
| type Target (Split f g) Source # | |
| data ScaleOptions (Split f g) a (b, c) Source # | |
Defined in Data.H3.Scales | |
| type TargetRange (Split f g) (b, c) Source # | |
Defined in Data.H3.Scales | |
A type that is the result of a binary function
Instances
| ProductV Void Source # | |
Defined in Data.H3.Scales | |
| ProductV (Either a b) Source # | |
Defined in Data.H3.Scales | |
| ProductV (a, b) Source # | |
Defined in Data.H3.Scales | |
Data family instance constructors
data family ScaleOptions f a b :: * Source #
Additional parameters for the scale (other than target range).