Copyright | (C) 2016 Christopher Chalmers |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Christopher Chalmers |

Stability | experimental |

Portability | non-portable |

Safe Haskell | None |

Language | Haskell2010 |

A pie plot is a circular statistical graphic, which is divided into slices to illustrate numerical proportion.

(see `piePlot`

example for code to make this plot)

## Synopsis

- data PieState b n a
- piePlot :: (MonadState (Axis b Polar n) m, Plotable (Wedge n) b, Foldable f) => f a -> (a -> n) -> State (PieState b n a) () -> m ()
- piePlot' :: (MonadState (Axis b Polar n) m, Plotable (Wedge n) b, Foldable f) => f n -> m ()
- onWedges :: (a -> State (Plot (Wedge n) b) ()) -> State (PieState b n a) ()
- wedgeKeys :: Num n => (a -> String) -> State (PieState b n a) ()
- data Wedge n
- mkWedge :: Num n => Direction V2 n -> Angle n -> Wedge n
- class HasWedge f a where
- pieWedge :: LensLike' f a (Wedge (N a))
- wedgeOuterRadius :: Functor f => LensLike' f a (N a)
- wedgeInnerRadius :: Functor f => LensLike' f a (N a)
- wedgeOffset :: Functor f => LensLike' f a (N a)
- wedgeWidth :: Functor f => LensLike' f a (Angle (N a))
- wedgeDirection :: Functor f => LensLike' f a (Direction V2 (N a))

- wedgePlot :: (v ~ BaseSpace c, v ~ V2, PointLike v n (Polar n), MonadState (Axis b c n) m, Plotable (Wedge n) b) => Direction V2 n -> Angle n -> State (Plot (Wedge n) b) () -> m ()

# Pie plot

The state used to draw a part chart made of multiple pie wedges.

## Instances

Applicative f => HasWedge f (PieState b n a) Source # | |

Defined in Plots.Types.Pie pieWedge :: LensLike' f (PieState b n a) (Wedge (N (PieState b n a))) Source # wedgeOuterRadius :: LensLike' f (PieState b n a) (N (PieState b n a)) Source # wedgeInnerRadius :: LensLike' f (PieState b n a) (N (PieState b n a)) Source # wedgeOffset :: LensLike' f (PieState b n a) (N (PieState b n a)) Source # wedgeWidth :: LensLike' f (PieState b n a) (Angle (N (PieState b n a))) Source # wedgeDirection :: LensLike' f (PieState b n a) (Direction V2 (N (PieState b n a))) Source # | |

type N (PieState b n a) Source # | |

Defined in Plots.Types.Pie type N (PieState b n a) = n | |

type V (PieState b n a) Source # | |

Defined in Plots.Types.Pie |

:: (MonadState (Axis b Polar n) m, Plotable (Wedge n) b, Foldable f) | |

=> f a | data for each wedge |

-> (a -> n) | extract weight of each wedge |

-> State (PieState b n a) () | |

-> m () |

Make a pie plot from a list of data by making a series of wedge plots.

### Example

import Plots pieData = [("red", 3), ("blue", 4), ("green", 2), ("purple", 5)] piePlotAxis :: Axis B Polar Double piePlotAxis = polarAxis &~ do piePlot pieData snd $ wedgeKeys fst hide (axes . traversed)

piePlotExample = renderAxis piePlotAxis

:: (MonadState (Axis b Polar n) m, Plotable (Wedge n) b, Foldable f) | |

=> f n | weight of each wedge |

-> m () |

Make a pie plot from list of values without any changes.

### Example

import Plots piePlotAxis' :: Axis B Polar Double piePlotAxis' = polarAxis &~ do piePlot' [1,3,5,2] wedgeInnerRadius .= 0.5 hide (axes . traversed)

pieExample' = renderAxis piePlotAxis'

onWedges :: (a -> State (Plot (Wedge n) b) ()) -> State (PieState b n a) () Source #

Modify the state for each wedge given the data entry.

Some common lenses to use on the `Wedge`

:

`plotColour`

- change the colour of the bars`areaStyle`

- modify the style of the bars`key`

- add a legend entry for that group of bars`wedgeOffset`

- the offset of the wedge from the center

wedgeKeys :: Num n => (a -> String) -> State (PieState b n a) () Source #

Add a legend entry for each item given a function that extracts the item's name.

# Wedges

Contains information to draw a single wedge of a pie. It is not
intended to be drawn directly. Instead use `piePlot`

.

## Instances

HasWedge f (Wedge n) Source # | |

Defined in Plots.Types.Pie pieWedge :: LensLike' f (Wedge n) (Wedge (N (Wedge n))) Source # wedgeOuterRadius :: LensLike' f (Wedge n) (N (Wedge n)) Source # wedgeInnerRadius :: LensLike' f (Wedge n) (N (Wedge n)) Source # wedgeOffset :: LensLike' f (Wedge n) (N (Wedge n)) Source # wedgeWidth :: LensLike' f (Wedge n) (Angle (N (Wedge n))) Source # wedgeDirection :: LensLike' f (Wedge n) (Direction V2 (N (Wedge n))) Source # | |

RealFloat n => Enveloped (Wedge n) Source # | |

Defined in Plots.Types.Pie getEnvelope :: Wedge n -> Envelope (V (Wedge n)) (N (Wedge n)) | |

(TypeableFloat n, Renderable (Path V2 n) b) => Plotable (Wedge n) b Source # | |

type N (Wedge n) Source # | |

Defined in Plots.Types.Pie type N (Wedge n) = n | |

type V (Wedge n) Source # | |

Defined in Plots.Types.Pie |

Create a pie wedge with unit radius, starting at direction `d`

with
width `theta`

.

class HasWedge f a where Source #

pieWedge :: LensLike' f a (Wedge (N a)) Source #

Description on how to draw a wedge.

wedgeOuterRadius :: Functor f => LensLike' f a (N a) Source #

The outside radius of the wedge. Default is `1`

.

wedgeInnerRadius :: Functor f => LensLike' f a (N a) Source #

The inside radius of the wedge. Default is $0$.

wedgeOffset :: Functor f => LensLike' f a (N a) Source #

The offset of the wedge from the center.

wedgeWidth :: Functor f => LensLike' f a (Angle (N a)) Source #

The width of the wedge, starting from the `wedgeDirection`

.

wedgeDirection :: Functor f => LensLike' f a (Direction V2 (N a)) Source #

The inititial direction of the wedge.

## Instances

wedgePlot :: (v ~ BaseSpace c, v ~ V2, PointLike v n (Polar n), MonadState (Axis b c n) m, Plotable (Wedge n) b) => Direction V2 n -> Angle n -> State (Plot (Wedge n) b) () -> m () Source #

Add a single `PiePlot`

to the `AxisState`

from a data set.

### Example

import Plots wedgePlotAxis :: Axis B Polar Double wedgePlotAxis = polarAxis &~ do wedgePlot xDir (38@@deg) $ key "wedge"

wedgeExample = renderAxis wedgePlotAxis