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

Safe Haskell | None

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 :: CRender RectSize
  - render :: RectSize -> CRender (PickFn a)
  }
- class ToRenderable a where
  - toRenderable :: a -> Renderable ()
- type PickFn a = Point -> Maybe a
- renderableToPNGFile :: Renderable a -> Int -> Int -> FilePath -> IO (PickFn a)
- renderableToPDFFile :: Renderable a -> Int -> Int -> FilePath -> IO ()
- renderableToPSFile :: Renderable a -> Int -> Int -> FilePath -> IO ()
- renderableToSVGFile :: Renderable a -> Int -> Int -> FilePath -> IO ()
- vectorEnv :: CEnv
- bitmapEnv :: CEnv
- fillBackground :: CairoFillStyle -> Renderable a -> Renderable a
- addMargins :: (Double, Double, Double, Double) -> Renderable a -> Renderable a
- emptyRenderable :: Renderable a
- embedRenderable :: CRender (Renderable a) -> Renderable a
- label :: CairoFontStyle -> HTextAnchor -> VTextAnchor -> String -> Renderable String
- rlabel :: CairoFontStyle -> 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 :: Accessor Rectangle RectSize
- rect_fillStyle :: Accessor Rectangle (Maybe CairoFillStyle)
- rect_lineStyle :: Accessor Rectangle (Maybe CairoLineStyle)
- rect_cornerStyle :: Accessor Rectangle RectCornerStyle

# Documentation

data Renderable a Source

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

Constructors

Renderable |

Fields

minsize :: CRender RectSize

  A Cairo action to calculate a minimum size.

render :: RectSize -> CRender (PickFn a)

  A Cairo action for drawing it within a rectangle. The rectangle is from the origin to the given point.

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

class ToRenderable a where Source

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

Methods

toRenderable :: a -> Renderable ()Source

Instances

ToRenderable PieChart |
ToRenderable PieLayout |
ToRenderable SparkLine |
ToRenderable Layout1DDD |
ToRenderable a => ToRenderable (Grid a) |
ToRenderable (Legend x y) |
(Ord x, Ord y) => ToRenderable (Layout1 x y) |

type PickFn a = Point -> Maybe aSource

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.

renderableToPNGFile :: Renderable a -> Int -> Int -> FilePath -> IO (PickFn a)Source

Output the given renderable to a PNG file of the specifed size (in pixels), to the specified file.

renderableToPDFFile :: Renderable a -> Int -> Int -> FilePath -> IO ()Source

Output the given renderable to a PDF file of the specifed size (in points), to the specified file.

renderableToPSFile :: Renderable a -> Int -> Int -> FilePath -> IO ()Source

Output the given renderable to a postscript file of the specifed size (in points), to the specified file.

renderableToSVGFile :: Renderable a -> Int -> Int -> FilePath -> IO ()Source

Output the given renderable to an SVG file of the specifed size (in points), to the specified file.

vectorEnv :: CEnv Source

bitmapEnv :: CEnv Source

fillBackground :: CairoFillStyle -> Renderable a -> Renderable aSource

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 aSource

embedRenderable :: CRender (Renderable a) -> Renderable aSource

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

label :: CairoFontStyle -> HTextAnchor -> VTextAnchor -> String -> Renderable String Source

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

rlabel :: CairoFontStyle -> 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.

spacer :: RectSize -> Renderable aSource

Create a blank renderable with a specified minimum size.

spacer1 :: Renderable a -> Renderable bSource

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

setPickFn :: PickFn b -> Renderable a -> Renderable bSource

Replace the pick function of a renderable with another.

mapMaybePickFn :: (a -> Maybe b) -> Renderable a -> Renderable bSource

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

mapPickFn :: (a -> b) -> Renderable a -> Renderable bSource

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

nullPickFn :: PickFn aSource

rect_minsize :: Accessor Rectangle RectSize Source

Accessor for field rect_minsize_.

rect_fillStyle :: Accessor Rectangle (Maybe CairoFillStyle)Source

Accessor for field rect_fillStyle_.

rect_lineStyle :: Accessor Rectangle (Maybe CairoLineStyle)Source

Accessor for field rect_lineStyle_.

rect_cornerStyle :: Accessor Rectangle RectCornerStyleSource

Accessor for field rect_cornerStyle_.