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

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

Graphics.Rendering.Chart.Renderable

Description

This module contains the definition of the `Renderable` type, which is a composable drawing element, along with assorted functions to them.

Synopsis

- data Renderable a = Renderable {
  - minsize :: BackendProgram RectSize
  - render :: RectSize -> BackendProgram (PickFn a)
  }
- class ToRenderable a where
  - toRenderable :: a -> Renderable ()
- type PickFn a = Point -> Maybe a
- data Rectangle = Rectangle {
  - _rect_minsize :: RectSize
  - _rect_fillStyle :: Maybe FillStyle
  - _rect_lineStyle :: Maybe LineStyle
  - _rect_cornerStyle :: RectCornerStyle
  }
- data RectCornerStyle
  - = RCornerSquare
  - | RCornerBevel Double
  - | RCornerRounded Double
- rectangleToRenderable :: Rectangle -> Renderable a
- drawRectangle :: Point -> Rectangle -> BackendProgram (PickFn a)
- fillBackground :: FillStyle -> Renderable a -> Renderable a
- addMargins :: (Double, Double, Double, Double) -> Renderable a -> Renderable a
- emptyRenderable :: Renderable a
- embedRenderable :: BackendProgram (Renderable a) -> Renderable a
- label :: FontStyle -> HTextAnchor -> VTextAnchor -> String -> Renderable String
- rlabel :: FontStyle -> HTextAnchor -> VTextAnchor -> Double -> String -> Renderable String
- spacer :: RectSize -> Renderable a
- spacer1 :: Renderable a -> Renderable b
- setPickFn :: PickFn b -> Renderable a -> Renderable b
- mapMaybePickFn :: (a -> Maybe b) -> Renderable a -> Renderable b
- mapPickFn :: (a -> b) -> Renderable a -> Renderable b
- nullPickFn :: PickFn a
- rect_minsize :: Lens' Rectangle RectSize
- rect_fillStyle :: Lens' Rectangle (Maybe FillStyle)
- rect_lineStyle :: Lens' Rectangle (Maybe LineStyle)
- rect_cornerStyle :: Lens' Rectangle RectCornerStyle

# Documentation

data Renderable a Source #

A Renderable is a record of functions required to layout a graphic element.

Constructors

Renderable |

Fields

- minsize :: BackendProgram RectSize

  Calculate the minimum size of the renderable.

- render :: RectSize -> BackendProgram (PickFn a)

  Draw the renderable with a rectangle, which covers the origin to a given point.

  The resulting "pick" function maps a point in the image to a value.

#### Instances

Instances details

Functor Renderable Source # |
Instance details Defined in Graphics.Rendering.Chart.Renderable Methods fmap :: (a -> b) -> Renderable a -> Renderable b (<$) :: a -> Renderable b -> Renderable a
ToRenderable (Renderable a) Source # |
Instance details Defined in Graphics.Rendering.Chart.Renderable Methods toRenderable :: Renderable a -> Renderable () Source #

class ToRenderable a where Source #

A type class abtracting the conversion of a value to a Renderable.

Methods

toRenderable :: a -> Renderable () Source #

#### Instances

Instances details

ToRenderable Rectangle Source # |
Instance details Defined in Graphics.Rendering.Chart.Renderable Methods toRenderable :: Rectangle -> Renderable () Source #
ToRenderable SparkLine Source # |
Instance details Defined in Graphics.Rendering.Chart.SparkLine Methods toRenderable :: SparkLine -> Renderable () Source #
ToRenderable PieChart Source # |
Instance details Defined in Graphics.Rendering.Chart.Plot.Pie Methods toRenderable :: PieChart -> Renderable () Source #
ToRenderable PieLayout Source # |
Instance details Defined in Graphics.Rendering.Chart.Plot.Pie Methods toRenderable :: PieLayout -> Renderable () Source #
ToRenderable (Renderable a) Source # |
Instance details Defined in Graphics.Rendering.Chart.Renderable Methods toRenderable :: Renderable a -> Renderable () Source #
ToRenderable a => ToRenderable (Grid a) Source # |
Instance details Defined in Graphics.Rendering.Chart.Grid Methods toRenderable :: Grid a -> Renderable () Source #
Ord x => ToRenderable (StackedLayouts x) Source # |
Instance details Defined in Graphics.Rendering.Chart.Layout Methods toRenderable :: StackedLayouts x -> Renderable () Source #
ToRenderable (Legend x y) Source # |
Instance details Defined in Graphics.Rendering.Chart.Legend Methods toRenderable :: Legend x y -> Renderable () Source #
(Ord x, Ord y) => ToRenderable (Layout x y) Source # |
Instance details Defined in Graphics.Rendering.Chart.Layout Methods toRenderable :: Layout x y -> Renderable () Source #
(Default a, ToRenderable a) => ToRenderable (EC a b) Source # |
Instance details Defined in Graphics.Rendering.Chart.State Methods toRenderable :: EC a b -> Renderable () Source #
(Ord x, Ord yl, Ord yr) => ToRenderable (LayoutLR x yl yr) Source # |
Instance details Defined in Graphics.Rendering.Chart.Layout Methods toRenderable :: LayoutLR x yl yr -> Renderable () Source #

type PickFn a = Point -> Maybe a Source #

A function that maps a point in device coordinates to some value.

Perhaps it might be generalised from Maybe a to (MonadPlus m ) => m a in the future.

data Rectangle Source #

Constructors

Rectangle |

Fields

- _rect_minsize :: RectSize
- _rect_fillStyle :: Maybe FillStyle
- _rect_lineStyle :: Maybe LineStyle
- _rect_cornerStyle :: RectCornerStyle

#### Instances

Instances details

Default Rectangle Source # |
Instance details Defined in Graphics.Rendering.Chart.Renderable Methods def :: Rectangle Source #
ToRenderable Rectangle Source # |
Instance details Defined in Graphics.Rendering.Chart.Renderable Methods toRenderable :: Rectangle -> Renderable () Source #

data RectCornerStyle Source #

Constructors

RCornerSquare |
RCornerBevel Double |
RCornerRounded Double |

rectangleToRenderable :: Rectangle -> Renderable a Source #

drawRectangle :: Point -> Rectangle -> BackendProgram (PickFn a) Source #

Draw the specified rectangle such that its top-left vertex is placed at the given position

fillBackground :: FillStyle -> Renderable a -> Renderable a Source #

Overlay a renderable over a solid background fill.

addMargins Source #

Arguments

:: (Double, Double, Double, Double) | The spacing to be added.
-> Renderable a | The source renderable.
-> Renderable a |

Add some spacing at the edges of a renderable.

emptyRenderable :: Renderable a Source #

embedRenderable :: BackendProgram (Renderable a) -> Renderable a Source #

Helper function for using a renderable, when we generate it in the BackendProgram monad.

label :: FontStyle -> HTextAnchor -> VTextAnchor -> String -> Renderable String Source #

Construct a renderable from a text string, aligned with the axes.

rlabel :: FontStyle -> HTextAnchor -> VTextAnchor -> Double -> String -> Renderable String Source #

Construct a renderable from a text string, rotated wrt to axes. The angle of rotation is in degrees, measured clockwise from the horizontal.

spacer :: RectSize -> Renderable a Source #

Create a blank renderable with a specified minimum size.

spacer1 :: Renderable a -> Renderable b Source #

Create a blank renderable with a minimum size the same as some other renderable.

setPickFn :: PickFn b -> Renderable a -> Renderable b Source #

Replace the pick function of a renderable with another.

mapMaybePickFn :: (a -> Maybe b) -> Renderable a -> Renderable b Source #

Map a function over the result of a renderable's pickfunction, keeping only `Just` results.

mapPickFn :: (a -> b) -> Renderable a -> Renderable b Source #

Map a function over result of a renderable's pickfunction.

nullPickFn :: PickFn a Source #

rect_minsize :: Lens' Rectangle RectSize Source #

rect_fillStyle :: Lens' Rectangle (Maybe FillStyle) Source #

rect_lineStyle :: Lens' Rectangle (Maybe LineStyle) Source #

rect_cornerStyle :: Lens' Rectangle RectCornerStyle Source #