-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for generating 2D Charts and Plots -- -- A library for generating 2D Charts and Plots, based upon the cairo -- graphics library. @package Chart @version 0.13.1 -- | This module contains basic types and functions used for drawing. -- -- Note that template haskell is used to derive accessor functions (see -- Data.Accessor) for each field of the following data types: -- --
-- f :: Data.Accessor.Accessor D F --module Graphics.Rendering.Chart.Types -- | A rectangle is defined by two points. data Rect Rect :: Point -> Point -> Rect -- | A point in two dimensions. data Point Point :: Double -> Double -> Point p_x :: Point -> Double p_y :: Point -> Double data Vector Vector :: Double -> Double -> Vector v_x :: Vector -> Double v_y :: Vector -> Double type RectSize = (Double, Double) type Range = (Double, Double) -- | Create a rectangle based upon the coordinates of 4 points. mkrect :: Point -> Point -> Point -> Point -> Rect -- | Add a point and a vector. pvadd :: Point -> Vector -> Point -- | Subtract a vector from a point. pvsub :: Point -> Vector -> Point -- | Subtract two points. psub :: Point -> Point -> Vector -- | Scale a vector by a constant. vscale :: Double -> Vector -> Vector -- | Test if a point is within a rectangle. within :: Point -> Rect -> Bool data RectEdge E_Top :: RectEdge E_Bottom :: RectEdge E_Left :: RectEdge E_Right :: RectEdge data Limit a LMin :: Limit a LValue :: a -> Limit a LMax :: Limit a -- | A function mapping between points. type PointMapFn x y = (Limit x, Limit y) -> Point -- | Execute a rendering action in a saved context (ie bracketed between -- C.save and C.restore). preserveCState :: CRender a -> CRender a setClipRegion :: Point -> Point -> CRender () moveTo :: Point -> CRender () lineTo :: Point -> CRender () -- | Make a path from a rectangle. rectPath :: Rect -> [Point] -- | Draw lines between the specified points. -- -- The points will be corrected by the cenv_point_alignfn, so that -- when drawing bitmaps, 1 pixel wide lines will be centred on the -- pixels. strokePath :: [Point] -> CRender () -- | Fill the region with the given corners. -- -- The points will be corrected by the cenv_coord_alignfn, so that -- when drawing bitmaps, the edges of the region will fall between -- pixels. fillPath :: [Point] -> CRender () isValidNumber :: (RealFloat a) => a -> Bool maybeM :: (Monad m) => b -> (a -> m b) -> Maybe a -> m b defaultColorSeq :: [AlphaColour Double] setSourceColor :: AlphaColour Double -> Render () -- | Data type for the style of a line. data CairoLineStyle CairoLineStyle :: Double -> AlphaColour Double -> [Double] -> LineCap -> LineJoin -> CairoLineStyle line_width_ :: CairoLineStyle -> Double line_color_ :: CairoLineStyle -> AlphaColour Double line_dashes_ :: CairoLineStyle -> [Double] line_cap_ :: CairoLineStyle -> LineCap line_join_ :: CairoLineStyle -> LineJoin solidLine :: Double -> AlphaColour Double -> CairoLineStyle dashedLine :: Double -> [Double] -> AlphaColour Double -> CairoLineStyle setLineStyle :: CairoLineStyle -> CRender () -- | Abstract data type for a fill style. -- -- The contained Cairo action sets the required fill style in the Cairo -- rendering state. newtype CairoFillStyle CairoFillStyle :: (CRender ()) -> CairoFillStyle defaultPointStyle :: CairoPointStyle solidFillStyle :: AlphaColour Double -> CairoFillStyle setFillStyle :: CairoFillStyle -> CRender () -- | Data type for a font. data CairoFontStyle CairoFontStyle :: String -> Double -> FontSlant -> FontWeight -> AlphaColour Double -> CairoFontStyle font_name_ :: CairoFontStyle -> String font_size_ :: CairoFontStyle -> Double font_slant_ :: CairoFontStyle -> FontSlant font_weight_ :: CairoFontStyle -> FontWeight font_color_ :: CairoFontStyle -> AlphaColour Double defaultFontStyle :: CairoFontStyle setFontStyle :: CairoFontStyle -> CRender () -- | Abstract data type for the style of a plotted point. -- -- The contained Cairo action draws a point in the desired style, at the -- supplied device coordinates. newtype CairoPointStyle CairoPointStyle :: (Point -> CRender ()) -> CairoPointStyle filledPolygon :: Double -> Int -> Bool -> AlphaColour Double -> CairoPointStyle hollowPolygon :: Double -> Double -> Int -> Bool -> AlphaColour Double -> CairoPointStyle filledCircles :: Double -> AlphaColour Double -> CairoPointStyle hollowCircles :: Double -> Double -> AlphaColour Double -> CairoPointStyle plusses :: Double -> Double -> AlphaColour Double -> CairoPointStyle exes :: Double -> Double -> AlphaColour Double -> CairoPointStyle stars :: Double -> Double -> AlphaColour Double -> CairoPointStyle data HTextAnchor HTA_Left :: HTextAnchor HTA_Centre :: HTextAnchor HTA_Right :: HTextAnchor data VTextAnchor VTA_Top :: VTextAnchor VTA_Centre :: VTextAnchor VTA_Bottom :: VTextAnchor VTA_BaseLine :: VTextAnchor -- | Function to draw a textual label anchored by one of its corners or -- edges. drawText :: HTextAnchor -> VTextAnchor -> Point -> String -> CRender () -- | Function to draw a textual label anchored by one of its corners or -- edges, with rotation. Rotation angle is given in degrees, rotation is -- performed around anchor point. drawTextR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> CRender () -- | Return the bounding rectangle for a text string rendered in the -- current context. textSize :: String -> CRender RectSize -- | The reader monad containing context information to control the -- rendering process. newtype CRender a DR :: (ReaderT CEnv Render a) -> CRender a -- | The environment present in the CRender Monad. data CEnv CEnv :: (Point -> Point) -> (Point -> Point) -> CEnv -- | An adjustment applied immediately prior to points being displayed in -- device coordinates. -- -- When device coordinates correspond to pixels, a cleaner image is -- created if this transform rounds to the nearest pixel. With -- higher-resolution output, this transform can just be the identity -- function. cenv_point_alignfn :: CEnv -> Point -> Point -- | A adjustment applied immediately prior to coordinates being -- transformed. cenv_coord_alignfn :: CEnv -> Point -> Point runCRender :: CRender a -> CEnv -> Render a c :: Render a -> CRender a alignp :: Point -> CRender Point alignc :: Point -> CRender Point line_width :: T CairoLineStyle Double line_color :: T CairoLineStyle (AlphaColour Double) line_dashes :: T CairoLineStyle ([] Double) line_cap :: T CairoLineStyle LineCap line_join :: T CairoLineStyle LineJoin font_name :: T CairoFontStyle String font_size :: T CairoFontStyle Double font_slant :: T CairoFontStyle FontSlant font_weight :: T CairoFontStyle FontWeight font_color :: T CairoFontStyle (AlphaColour Double) instance Functor CRender instance Monad CRender instance MonadReader CEnv CRender instance Show Rect instance (Show a) => Show (Limit a) instance Show Vector instance Show Point -- | This module contains the definition of the Renderable type, -- which is a composable drawing element, along with assorted functions -- to them. module Graphics.Rendering.Chart.Renderable -- | A Renderable is a record of functions required to layout a graphic -- element. data Renderable a Renderable :: CRender RectSize -> (RectSize -> CRender (PickFn a)) -> Renderable a -- | A Cairo action to calculate a minimum size. minsize :: Renderable a -> CRender RectSize -- | 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. render :: Renderable a -> RectSize -> CRender (PickFn a) -- | A type class abtracting the conversion of a value to a Renderable. class ToRenderable a toRenderable :: (ToRenderable a) => a -> Renderable () -- | 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. type PickFn a = Point -> (Maybe a) -- | Output the given renderable to a PNG file of the specifed size (in -- pixels), to the specified file. renderableToPNGFile :: Renderable a -> Int -> Int -> FilePath -> IO () -- | Output the given renderable to a PDF file of the specifed size (in -- points), to the specified file. renderableToPDFFile :: Renderable a -> Int -> Int -> FilePath -> IO () -- | Output the given renderable to a postscript file of the specifed size -- (in points), to the specified file. renderableToPSFile :: Renderable a -> Int -> Int -> FilePath -> IO () -- | Output the given renderable to an SVG file of the specifed size (in -- points), to the specified file. renderableToSVGFile :: Renderable a -> Int -> Int -> FilePath -> IO () vectorEnv :: CEnv bitmapEnv :: CEnv -- | Overlay a renderable over a solid background fill. fillBackground :: CairoFillStyle -> Renderable a -> Renderable a -- | Add some spacing at the edges of a renderable. addMargins :: (Double, Double, Double, Double) -> Renderable a -> Renderable a emptyRenderable :: Renderable a -- | Helper function for using a renderable, when we generate it in the -- CRender monad. embedRenderable :: CRender (Renderable a) -> Renderable a -- | Construct a renderable from a text string, aligned with the axes. label :: CairoFontStyle -> HTextAnchor -> VTextAnchor -> String -> Renderable a -- | Construct a renderable from a text string, rotated wrt to axes. The -- angle of rotation is in degrees. rlabel :: CairoFontStyle -> HTextAnchor -> VTextAnchor -> Double -> String -> Renderable a -- | Create a blank renderable with a specified minimum size. spacer :: RectSize -> Renderable a -- | Create a blank renderable with a minimum size the same as some other -- renderable. spacer1 :: Renderable a -> Renderable b -- | Replace the pick function of a renderable with another. setPickFn :: PickFn b -> Renderable a -> Renderable b -- | Map a function over result of a renderable's pickfunction. mapPickFn :: (a -> b) -> Renderable a -> Renderable b nullPickFn :: PickFn a -- | Accessor for field rect_minsize_. rect_minsize :: Accessor Rectangle RectSize -- | Accessor for field rect_fillStyle_. rect_fillStyle :: Accessor Rectangle (Maybe CairoFillStyle) -- | Accessor for field rect_lineStyle_. rect_lineStyle :: Accessor Rectangle (Maybe CairoLineStyle) -- | Accessor for field rect_cornerStyle_. rect_cornerStyle :: Accessor Rectangle RectCornerStyle instance ToRenderable Rectangle -- | Code to calculate and render axes. -- -- Note that template haskell is used to derive accessor functions (see -- Data.Accessor) for each field of the following data types: -- --
-- f :: Data.Accessor.Accessor D F --module Graphics.Rendering.Chart.Axis -- | The basic data associated with an axis showing values of type x. data AxisData x AxisData :: (Range -> x -> Double) -> [(x, Double)] -> [(x, String)] -> [x] -> AxisData x -- | The axis_viewport_ function maps values into device coordinates. axis_viewport_ :: AxisData x -> Range -> x -> Double -- | The tick marks on the axis as pairs. The first element is the position -- on the axis (in viewport units) and the second element is the length -- of the tick in output coordinates. The tick starts on the axis, and -- positive numbers are drawn towards the plot area. axis_ticks_ :: AxisData x -> [(x, Double)] -- | The labels on an axis as pairs. The first element is the position on -- the axis (in viewport units) and the second is the label text string. axis_labels_ :: AxisData x -> [(x, String)] -- | The positions on the axis (in viewport units) where we want to show -- grid lines. axis_grid_ :: AxisData x -> [x] -- | Collect the information we need to render an axis. The bool is true if -- the axis direction is reversed. data AxisT x AxisT :: RectEdge -> AxisStyle -> Bool -> (AxisData x) -> AxisT x data LinearAxisParams a LinearAxisParams :: (a -> String) -> Int -> Int -> LinearAxisParams a -- | The function used to show the axes labels. la_labelf_ :: LinearAxisParams a -> a -> String -- | The target number of labels to be shown. la_nLabels_ :: LinearAxisParams a -> Int -- | The target number of ticks to be shown. la_nTicks_ :: LinearAxisParams a -> Int data LogAxisParams a LogAxisParams :: (a -> String) -> LogAxisParams a -- | The function used to show the axes labels. loga_labelf_ :: LogAxisParams a -> a -> String -- | Control values for how an axis gets displayed. data AxisStyle AxisStyle :: CairoLineStyle -> CairoFontStyle -> CairoLineStyle -> Double -> AxisStyle axis_line_style_ :: AxisStyle -> CairoLineStyle axis_label_style_ :: AxisStyle -> CairoFontStyle axis_grid_style_ :: AxisStyle -> CairoLineStyle -- | How far the labels are to be drawn from the axis. axis_label_gap_ :: AxisStyle -> Double class (Ord a) => PlotValue a toValue :: (PlotValue a) => a -> Double autoAxis :: (PlotValue a) => AxisFn a newtype LogValue LogValue :: Double -> LogValue -- | Type for capturing values plotted by index number (ie position in a -- list) rather than a numerical value. newtype PlotIndex PlotIndex :: Int -> PlotIndex plotindex_i :: PlotIndex -> Int -- | A function to generate the axis data, given the data values to be -- plotted against it. type AxisFn x = [x] -> AxisData x defaultAxisLineStyle :: CairoLineStyle defaultLinearAxis :: (Show a) => LinearAxisParams a defaultIntAxis :: (Show a) => LinearAxisParams a defaultLogAxis :: (Show a) => LogAxisParams a defaultAxisStyle :: AxisStyle -- | Generate a linear axis automatically. The supplied axis is used as a -- template, with the viewport, ticks, labels and grid set appropriately -- for the data displayed against that axies. The resulting axis will -- only show a grid if the template has some grid values. autoScaledAxis :: (RealFloat a) => LinearAxisParams a -> AxisFn a -- | Generate a log axis automatically. The supplied axis is used as a -- template, with the viewport, ticks, labels and grid set appropriately -- for the data displayed against that axis. The resulting axis will only -- show a grid if the template has some grid values. autoScaledLogAxis :: (RealFloat a) => LogAxisParams a -> AxisFn a unitAxis :: AxisData () -- | Create an AxisFn to for a time axis. The first TimeSeq -- sets the minor ticks, and the ultimate range will be aligned to its -- elements. The second TimeSeq sets the labels and grid. The -- TimeLabelFn is used to format LocalTimes for labels. The values -- to be plotted against this axis can be created with -- doubleFromLocalTime. timeAxis :: TimeSeq -> TimeSeq -> TimeLabelFn -> AxisFn LocalTime -- | Automatically choose a suitable time axis, based upon the time range -- of data. The values to be plotted against this axis can be created -- with doubleFromLocalTime. autoTimeAxis :: AxisFn LocalTime -- | A TimeSeq for calendar days. days :: TimeSeq -- | A TimeSeq for calendar months. months :: TimeSeq -- | A TimeSeq for calendar years. years :: TimeSeq -- | Create an axis for values indexed by position. The list of strings are -- the labels to be used. autoIndexAxis :: (Integral i) => [String] -> [i] -> AxisData i -- | Augment a list of values with index numbers for plotting. addIndexes :: [a] -> [(PlotIndex, a)] -- | Given a target number of values, and a list of input points, find -- evenly spaced values from the set {1*X, 2*X, 2.5*X, 5*X} (where X is -- some power of ten) that evenly cover the input points. autoSteps :: Int -> [Double] -> [Double] axisToRenderable :: AxisT x -> Renderable x renderAxisGrid :: RectSize -> AxisT z -> CRender () -- | Calculate the amount by which the labels extend beyond the ends of the -- axis. axisOverhang :: (Ord x) => AxisT x -> CRender (Double, Double) -- | A linear mapping of points in one range to another. vmap :: (PlotValue x) => (x, x) -> Range -> x -> Double axisGridAtTicks :: AxisData x -> AxisData x axisGridAtLabels :: AxisData x -> AxisData x axisGridHide :: AxisData x -> AxisData x axisTicksHide :: AxisData x -> AxisData x axisLabelsHide :: AxisData x -> AxisData x axis_viewport :: T (AxisData x[afL6]) (Range -> x[afL6] -> Double) axis_ticks :: T (AxisData x[afL6]) ([] ((,) x[afL6] Double)) axis_labels :: T (AxisData x[afL6]) ([] ((,) x[afL6] String)) axis_grid :: T (AxisData x[afL6]) ([] x[afL6]) axis_line_style :: T AxisStyle CairoLineStyle axis_label_style :: T AxisStyle CairoFontStyle axis_grid_style :: T AxisStyle CairoLineStyle axis_label_gap :: T AxisStyle Double la_labelf :: T (LinearAxisParams a[afL3]) (a[afL3] -> String) la_nLabels :: T (LinearAxisParams a[afL3]) Int la_nTicks :: T (LinearAxisParams a[afL3]) Int loga_labelf :: T (LogAxisParams a[afL2]) (a[afL2] -> String) instance Eq PlotIndex instance Ord PlotIndex instance Enum PlotIndex instance Num PlotIndex instance Real PlotIndex instance Integral PlotIndex instance Show PlotIndex instance Eq LogValue instance Ord LogValue instance Num LogValue instance Real LogValue instance Fractional LogValue instance RealFrac LogValue instance Floating LogValue instance RealFloat LogValue instance PlotValue PlotIndex instance PlotValue LocalTime instance PlotValue () instance PlotValue Integer instance PlotValue Int instance PlotValue LogValue instance Show LogValue instance PlotValue Double instance ToRenderable (AxisT x) -- | Definitions of various types of Plots we can put on a 2D Chart. -- -- Note that template haskell is used to derive accessor functions (see -- Data.Accessor) for each field of the following data types: -- --
-- f :: Data.Accessor.Accessor D F --module Graphics.Rendering.Chart.Plot -- | Interface to control plotting on a 2D area. data Plot x y Plot :: (PointMapFn x y -> CRender ()) -> [(String, Rect -> CRender ())] -> ([x], [y]) -> Plot x y -- | Given the mapping between model space coordinates and device -- coordinates, render this plot into a chart. plot_render_ :: Plot x y -> PointMapFn x y -> CRender () -- | Details for how to show this plot in a legend. For each item the -- string is the text to show, and the function renders a graphical -- sample of the plot. plot_legend_ :: Plot x y -> [(String, Rect -> CRender ())] -- | All of the model space coordinates to be plotted. These are used to -- autoscale the axes where necessary. plot_all_points_ :: Plot x y -> ([x], [y]) -- | Join any two plots together (they will share a legend). joinPlot :: Plot x y -> Plot x y -> Plot x y -- | A type class abstracting the conversion of a value to a Plot. class ToPlot a toPlot :: (ToPlot a) => a x y -> Plot x y -- | Value defining a series of datapoints, and a style in which to render -- them. data PlotPoints x y PlotPoints :: String -> CairoPointStyle -> [(x, y)] -> PlotPoints x y plot_points_title_ :: PlotPoints x y -> String plot_points_style_ :: PlotPoints x y -> CairoPointStyle plot_points_values_ :: PlotPoints x y -> [(x, y)] defaultPlotPoints :: PlotPoints x y -- | Value defining a series of (possibly disjointed) lines, and a style in -- which to render them. data PlotLines x y PlotLines :: String -> CairoLineStyle -> [[(x, y)]] -> [[(Limit x, Limit y)]] -> PlotLines x y plot_lines_title_ :: PlotLines x y -> String plot_lines_style_ :: PlotLines x y -> CairoLineStyle plot_lines_values_ :: PlotLines x y -> [[(x, y)]] plot_lines_limit_values_ :: PlotLines x y -> [[(Limit x, Limit y)]] defaultPlotLines :: PlotLines x y defaultPlotLineStyle :: CairoLineStyle -- | Helper function to plot a single horizontal line. hlinePlot :: String -> CairoLineStyle -> b -> Plot a b -- | Helper function to plot a single vertical line. vlinePlot :: String -> CairoLineStyle -> a -> Plot a b -- | Value defining a series of error intervals, and a style in which to -- render them. data PlotErrBars x y PlotErrBars :: String -> CairoLineStyle -> Double -> Double -> [ErrPoint x y] -> PlotErrBars x y plot_errbars_title_ :: PlotErrBars x y -> String plot_errbars_line_style_ :: PlotErrBars x y -> CairoLineStyle plot_errbars_tick_length_ :: PlotErrBars x y -> Double plot_errbars_overhang_ :: PlotErrBars x y -> Double plot_errbars_values_ :: PlotErrBars x y -> [ErrPoint x y] defaultPlotErrBars :: PlotErrBars x y data ErrPoint x y ErrPoint :: ErrValue x -> ErrValue y -> ErrPoint x y ep_x :: ErrPoint x y -> ErrValue x ep_y :: ErrPoint x y -> ErrValue y -- | Value for holding a point with associated error bounds for each axis. data ErrValue x ErrValue :: x -> x -> x -> ErrValue x ev_low :: ErrValue x -> x ev_best :: ErrValue x -> x ev_high :: ErrValue x -> x -- | When the error is symmetric, we can simply pass in dx for the error. symErrPoint :: (Num a, Num b) => a -> b -> a -> b -> ErrPoint a b -- | Value specifying a plot filling the area between two sets of Y -- coordinates, given common X coordinates. data PlotFillBetween x y PlotFillBetween :: String -> CairoFillStyle -> [(x, (y, y))] -> PlotFillBetween x y plot_fillbetween_title_ :: PlotFillBetween x y -> String plot_fillbetween_style_ :: PlotFillBetween x y -> CairoFillStyle plot_fillbetween_values_ :: PlotFillBetween x y -> [(x, (y, y))] defaultPlotFillBetween :: PlotFillBetween x y -- | Value describing how to plot a set of bars. Note that the input data -- is typed [(x,[y])], ie for each x value we plot several y values. -- Typically the size of each [y] list would be the same. data PlotBars x y PlotBars :: PlotBarsStyle -> [(CairoFillStyle, Maybe CairoLineStyle)] -> [String] -> PlotBarsSpacing -> PlotBarsAlignment -> y -> Double -> [(x, [y])] -> PlotBars x y -- | This value specifies whether each value from [y] should be shown -- beside or above the previous value. plot_bars_style_ :: PlotBars x y -> PlotBarsStyle -- | The style in which to draw each element of [y]. A fill style is -- required, and if a linestyle is given, each bar will be outlined. plot_bars_item_styles_ :: PlotBars x y -> [(CairoFillStyle, Maybe CairoLineStyle)] -- | The title of each element of [y]. These will be shown in the legend. plot_bars_titles_ :: PlotBars x y -> [String] -- | This value controls how the widths of the bars are calculated. Either -- the widths of the bars, or the gaps between them can be fixed. plot_bars_spacing_ :: PlotBars x y -> PlotBarsSpacing -- | This value controls how bars for a fixed x are aligned with respect to -- the device coordinate corresponding to x. plot_bars_alignment_ :: PlotBars x y -> PlotBarsAlignment -- | The starting level for the chart (normally 0). plot_bars_reference_ :: PlotBars x y -> y plot_bars_singleton_width_ :: PlotBars x y -> Double -- | The actual points to be plotted. plot_bars_values_ :: PlotBars x y -> [(x, [y])] defaultPlotBars :: (BarsPlotValue y) => PlotBars x y data PlotBarsStyle -- | Bars for a fixed x are stacked vertically on top of each other. BarsStacked :: PlotBarsStyle -- | Bars for a fixed x are put horizontally beside each other. BarsClustered :: PlotBarsStyle data PlotBarsSpacing -- | All bars have the same width in pixels. BarsFixWidth :: Double -> PlotBarsSpacing -- | (BarsFixGap g mw) means make the gaps between the bars equal to g, but -- with a minimum bar width of mw BarsFixGap :: Double -> Double -> PlotBarsSpacing -- | How bars for a given (x,[y]) are aligned with respect to screen -- coordinate corresponding to x (deviceX). data PlotBarsAlignment -- | The left edge of bars is at deviceX BarsLeft :: PlotBarsAlignment -- | The right edge of bars is at deviceX BarsCentered :: PlotBarsAlignment -- | Bars are centered around deviceX BarsRight :: PlotBarsAlignment class (PlotValue a) => BarsPlotValue a barsReference :: (BarsPlotValue a) => a barsAdd :: (BarsPlotValue a) => a -> a -> a -- | Value defining some hidden x and y values. The values don't get -- displayed, but still affect axis scaling. data PlotHidden x y PlotHidden :: [x] -> [y] -> PlotHidden x y plot_hidden_x_values_ :: PlotHidden x y -> [x] plot_hidden_y_values_ :: PlotHidden x y -> [y] -- | Value for describing a series of text annotations to be placed at -- arbitrary points on the graph. Annotations can be rotated and styled. -- Rotation angle is given in degrees, rotation is performend around the -- anchor point. data PlotAnnotation x y PlotAnnotation :: HTextAnchor -> VTextAnchor -> Double -> CairoFontStyle -> [(x, y, String)] -> PlotAnnotation x y plot_annotation_hanchor_ :: PlotAnnotation x y -> HTextAnchor plot_annotation_vanchor_ :: PlotAnnotation x y -> VTextAnchor plot_annotation_angle_ :: PlotAnnotation x y -> Double plot_annotation_style_ :: PlotAnnotation x y -> CairoFontStyle plot_annotation_values_ :: PlotAnnotation x y -> [(x, y, String)] defaultPlotAnnotation :: PlotAnnotation x y plot_lines_title :: T (PlotLines x[awUc] y[awUd]) String plot_lines_style :: T (PlotLines x[awUc] y[awUd]) CairoLineStyle plot_lines_values :: T (PlotLines x[awUc] y[awUd]) ([] ([] ((,) x[awUc] y[awUd]))) plot_lines_limit_values :: T (PlotLines x[awUc] y[awUd]) ([] ([] ((,) (Limit x[awUc]) (Limit y[awUd])))) plot_render :: T (Plot x[awUh] y[awUi]) (PointMapFn x[awUh] y[awUi] -> CRender ()) plot_legend :: T (Plot x[awUh] y[awUi]) ([] ((,) String (Rect -> CRender ()))) plot_all_points :: T (Plot x[awUh] y[awUi]) ((,) ([] x[awUh]) ([] y[awUi])) plot_points_title :: T (PlotPoints x[awUa] y[awUb]) String plot_points_style :: T (PlotPoints x[awUa] y[awUb]) CairoPointStyle plot_points_values :: T (PlotPoints x[awUa] y[awUb]) ([] ((,) x[awUa] y[awUb])) plot_fillbetween_title :: T (PlotFillBetween x[awU8] y[awU9]) String plot_fillbetween_style :: T (PlotFillBetween x[awU8] y[awU9]) CairoFillStyle plot_fillbetween_values :: T (PlotFillBetween x[awU8] y[awU9]) ([] ((,) x[awU8] ((,) y[awU9] y[awU9]))) plot_errbars_title :: T (PlotErrBars x[awU3] y[awU4]) String plot_errbars_line_style :: T (PlotErrBars x[awU3] y[awU4]) CairoLineStyle plot_errbars_tick_length :: T (PlotErrBars x[awU3] y[awU4]) Double plot_errbars_overhang :: T (PlotErrBars x[awU3] y[awU4]) Double plot_errbars_values :: T (PlotErrBars x[awU3] y[awU4]) ([] (ErrPoint x[awU3] y[awU4])) plotBars :: (BarsPlotValue y) => PlotBars x y -> Plot x y plot_bars_style :: T (PlotBars x[awU0] y[awU1]) PlotBarsStyle plot_bars_item_styles :: T (PlotBars x[awU0] y[awU1]) ([] ((,) CairoFillStyle (Maybe CairoLineStyle))) plot_bars_titles :: T (PlotBars x[awU0] y[awU1]) ([] String) plot_bars_spacing :: T (PlotBars x[awU0] y[awU1]) PlotBarsSpacing plot_bars_alignment :: T (PlotBars x[awU0] y[awU1]) PlotBarsAlignment plot_bars_reference :: T (PlotBars x[awU0] y[awU1]) y[awU1] plot_bars_singleton_width :: T (PlotBars x[awU0] y[awU1]) Double plot_bars_values :: T (PlotBars x[awU0] y[awU1]) ([] ((,) x[awU0] ([] y[awU1]))) plot_annotation_hanchor :: T (PlotAnnotation x[awTW] y[awTX]) HTextAnchor plot_annotation_vanchor :: T (PlotAnnotation x[awTW] y[awTX]) VTextAnchor plot_annotation_angle :: T (PlotAnnotation x[awTW] y[awTX]) Double plot_annotation_style :: T (PlotAnnotation x[awTW] y[awTX]) CairoFontStyle plot_annotation_values :: T (PlotAnnotation x[awTW] y[awTX]) ([] ((,,) x[awTW] y[awTX] String)) instance Show PlotBarsAlignment instance Show PlotBarsSpacing instance Show PlotBarsStyle instance (Show x, Show y) => Show (ErrPoint x y) instance (Show x) => Show (ErrValue x) instance ToPlot PlotAnnotation instance ToPlot PlotHidden instance BarsPlotValue Int instance BarsPlotValue Double instance ToPlot PlotErrBars instance ToPlot PlotFillBetween instance ToPlot PlotPoints instance ToPlot PlotLines -- | Area spots are a collection of unconnected filled circles, with x,y -- position, and an independent z value to be represented by the relative -- area of the spots. module Graphics.Rendering.Chart.AreaSpots -- | A collection of unconnected spots, with x,y position, and an -- independent z value to be represented by the area of the spot. data AreaSpots z x y AreaSpots :: String -> Double -> AlphaColour Double -> AlphaColour Double -> Double -> [(x, y, z)] -> AreaSpots z x y area_spots_title_ :: AreaSpots z x y -> String area_spots_linethick_ :: AreaSpots z x y -> Double area_spots_linecolour_ :: AreaSpots z x y -> AlphaColour Double area_spots_fillcolour_ :: AreaSpots z x y -> AlphaColour Double -- | the largest size of spot area_spots_max_radius_ :: AreaSpots z x y -> Double area_spots_values_ :: AreaSpots z x y -> [(x, y, z)] defaultAreaSpots :: AreaSpots z x y area_spots_title :: T (AreaSpots z[aEzy] x[aEzz] y[aEzA]) String area_spots_linethick :: T (AreaSpots z[aEzy] x[aEzz] y[aEzA]) Double area_spots_linecolour :: T (AreaSpots z[aEzy] x[aEzz] y[aEzA]) (AlphaColour Double) area_spots_fillcolour :: T (AreaSpots z[aEzy] x[aEzz] y[aEzA]) (AlphaColour Double) area_spots_max_radius :: T (AreaSpots z[aEzy] x[aEzz] y[aEzA]) Double area_spots_values :: T (AreaSpots z[aEzy] x[aEzz] y[aEzA]) ([] ((,,) x[aEzz] y[aEzA] z[aEzy])) instance (PlotValue z) => ToPlot (AreaSpots z) module Graphics.Rendering.Chart.Grid -- | Abstract datatype representing a grid. data Grid a type Span = (Int, Int) -- | A 1x1 grid from a given value, with no extra space. tval :: a -> Grid a -- | A WxH (measured in cells) grid from a given value, with space weight -- (1,1). tspan :: a -> Span -> Grid a -- | A 1x1 empty grid. empty :: Grid a -- | A 0x0 empty grid. nullt :: Grid a -- | A synonym for beside. (.|.) :: Grid a -> Grid a -> Grid a -- | A synonym for above. (./.) :: Grid a -> Grid a -> Grid a above :: Grid a -> Grid a -> Grid a aboveN :: [Grid a] -> Grid a beside :: Grid a -> Grid a -> Grid a besideN :: [Grid a] -> Grid a -- | One grid over the other. The first argument is shallow, the second is -- deep. overlay :: Grid a -> Grid a -> Grid a width :: Grid a -> Int height :: Grid a -> Int gridToRenderable :: Grid (Renderable a) -> Renderable a -- | Sets the space weight of *every* cell of the grid to given value. weights :: SpaceWeight -> Grid a -> Grid a -- | A value placed above the grid, occupying 1 row with the same -- horizontal span as the grid. fullRowAbove :: a -> Double -> Grid a -> Grid a -- | A value placed below the grid, occupying 1 row with the same -- horizontal span as the grid. fullRowBelow :: a -> Double -> Grid a -> Grid a -- | A value placed to the left of the grid, occupying 1 column with the -- same vertical span as the grid. fullColLeft :: a -> Double -> Grid a -> Grid a -- | A value placed to the right of the grid, occupying 1 column with the -- same vertical span as the grid. fullColRight :: a -> Double -> Grid a -> Grid a -- | A value placed under a grid, with the same span as the grid. fullOverlayUnder :: a -> Grid a -> Grid a -- | A value placed over a grid, with the same span as the grid. fullOverlayOver :: a -> Grid a -> Grid a instance (Show a) => Show (Grid a) instance (ToRenderable a) => ToRenderable (Grid a) instance Functor Grid module Graphics.Rendering.Chart.Legend data Legend x y Legend :: LegendStyle -> [(String, Rect -> CRender ())] -> Legend x y data LegendStyle LegendStyle :: CairoFontStyle -> Double -> Double -> LegendOrientation -> LegendStyle legend_label_style_ :: LegendStyle -> CairoFontStyle legend_margin_ :: LegendStyle -> Double legend_plot_size_ :: LegendStyle -> Double legend_orientation_ :: LegendStyle -> LegendOrientation -- | Legends can be constructed in two orientations: in rows (where we -- specify the maximum number of columns), and in columns (where we -- specify the maximum number of rows) data LegendOrientation LORows :: Int -> LegendOrientation LOCols :: Int -> LegendOrientation defaultLegendStyle :: LegendStyle legendToRenderable :: Legend x y -> Renderable String legend_label_style :: T LegendStyle CairoFontStyle legend_margin :: T LegendStyle Double legend_plot_size :: T LegendStyle Double legend_orientation :: T LegendStyle LegendOrientation instance ToRenderable (Legend x y) -- | This module glues together axes and plots to actually create a -- renderable for a chart. -- -- Note that template haskell is used to derive accessor functions (see -- Data.Accessor) for each field of the following data types: -- --
-- f :: Data.Accessor.Accessor D F --module Graphics.Rendering.Chart.Layout -- | A Layout1 value is a single plot area, with optional: axes on each of -- the 4 sides; title at the top; legend at the bottom. It's -- parameterised by the types of values to be plotted on the horizonal -- and vertical axes. data Layout1 x y Layout1 :: CairoFillStyle -> Maybe CairoFillStyle -> String -> CairoFontStyle -> LayoutAxis x -> LayoutAxis x -> LayoutAxis y -> LayoutAxis y -> (([y], [y]) -> ([y], [y])) -> Double -> [Either (Plot x y) (Plot x y)] -> Maybe LegendStyle -> Bool -> Layout1 x y layout1_background_ :: Layout1 x y -> CairoFillStyle layout1_plot_background_ :: Layout1 x y -> Maybe CairoFillStyle layout1_title_ :: Layout1 x y -> String layout1_title_style_ :: Layout1 x y -> CairoFontStyle layout1_bottom_axis_ :: Layout1 x y -> LayoutAxis x layout1_top_axis_ :: Layout1 x y -> LayoutAxis x layout1_left_axis_ :: Layout1 x y -> LayoutAxis y layout1_right_axis_ :: Layout1 x y -> LayoutAxis y -- | Function to map points from the left/right plot to the left/right -- axes. The default value is id. layout1_yaxes_control_ :: Layout1 x y -> ([y], [y]) -> ([y], [y]) layout1_margin_ :: Layout1 x y -> Double layout1_plots_ :: Layout1 x y -> [Either (Plot x y) (Plot x y)] layout1_legend_ :: Layout1 x y -> Maybe LegendStyle -- | True if the grid is to be rendered on top of the Plots. layout1_grid_last_ :: Layout1 x y -> Bool data LayoutAxis x LayoutAxis :: CairoFontStyle -> String -> AxisStyle -> ([x] -> Bool) -> AxisFn x -> (AxisData x -> AxisData x) -> Bool -> LayoutAxis x laxis_title_style_ :: LayoutAxis x -> CairoFontStyle laxis_title_ :: LayoutAxis x -> String laxis_style_ :: LayoutAxis x -> AxisStyle -- | Function that determines whether an axis should be visible, based upon -- the points plotted on this axis. The default value is 'not.null'. laxis_visible_ :: LayoutAxis x -> [x] -> Bool -- | Function that generates the axis data, based upon the points plotted. -- The default value is autoAxis. laxis_generate_ :: LayoutAxis x -> AxisFn x -- | Function that can be used to override the generated axis data. The -- default value is id. laxis_override_ :: LayoutAxis x -> AxisData x -> AxisData x -- | True if left to right (bottom to top) is to show descending values. laxis_reverse_ :: LayoutAxis x -> Bool -- | A MAxisFn is a function that generates an (optional) axis -- given the points plotted against that axis. type MAxisFn t = [t] -> Maybe (AxisData t) defaultLayout1 :: (PlotValue x, PlotValue y) => Layout1 x y linkAxes :: ([a], [a]) -> ([a], [a]) independentAxes :: (a, b) -> (a, b) -- | Helper to update all axis styles on a Layout1 simultaneously. updateAllAxesStyles :: (AxisStyle -> AxisStyle) -> Layout1 x y -> Layout1 x y -- | Helper to set the forground color uniformly on a Layout1. setLayout1Foreground :: AlphaColour Double -> Layout1 x y -> Layout1 x y defaultLayoutAxis :: (PlotValue t) => LayoutAxis t laxis_title_style :: T (LayoutAxis x[aMnj]) CairoFontStyle laxis_title :: T (LayoutAxis x[aMnj]) String laxis_style :: T (LayoutAxis x[aMnj]) AxisStyle laxis_visible :: T (LayoutAxis x[aMnj]) ([] x[aMnj] -> Bool) laxis_generate :: T (LayoutAxis x[aMnj]) (AxisFn x[aMnj]) laxis_override :: T (LayoutAxis x[aMnj]) (AxisData x[aMnj] -> AxisData x[aMnj]) laxis_reverse :: T (LayoutAxis x[aMnj]) Bool layout1_background :: T (Layout1 x[aMnh] y[aMni]) CairoFillStyle layout1_plot_background :: T (Layout1 x[aMnh] y[aMni]) (Maybe CairoFillStyle) layout1_title :: T (Layout1 x[aMnh] y[aMni]) String layout1_title_style :: T (Layout1 x[aMnh] y[aMni]) CairoFontStyle layout1_left_axis :: T (Layout1 x[aMnh] y[aMni]) (LayoutAxis y[aMni]) layout1_right_axis :: T (Layout1 x[aMnh] y[aMni]) (LayoutAxis y[aMni]) layout1_top_axis :: T (Layout1 x[aMnh] y[aMni]) (LayoutAxis x[aMnh]) layout1_bottom_axis :: T (Layout1 x[aMnh] y[aMni]) (LayoutAxis x[aMnh]) layout1_yaxes_control :: T (Layout1 x[aMnh] y[aMni]) ((,) ([] y[aMni]) ([] y[aMni]) -> (,) ([] y[aMni]) ([] y[aMni])) layout1_margin :: T (Layout1 x[aMnh] y[aMni]) Double layout1_plots :: T (Layout1 x[aMnh] y[aMni]) ([] (Either (Plot x[aMnh] y[aMni]) (Plot x[aMnh] y[aMni]))) layout1_legend :: T (Layout1 x[aMnh] y[aMni]) (Maybe LegendStyle) layout1_grid_last :: T (Layout1 x[aMnh] y[aMni]) Bool -- | Render several layouts with the same abscissa type stacked so that -- their origins and axis titles are aligned horizontally with respect to -- each other. The exterior margins and background are taken from the -- first element. renderLayout1sStacked :: (Ord x) => [AnyLayout1 x] -> Renderable () -- | Encapsulates a Layout1 with a fixed abscissa type but arbitrary -- ordinate type. data AnyLayout1 x withAnyOrdinate :: (Ord x, Ord y) => Layout1 x y -> AnyLayout1 x instance (Ord x, Ord y) => ToRenderable (Layout1 x y) -- | A basic pie chart. -- -- Note that template haskell is used to derive accessor functions (see -- Data.Accessor) for each field of the following data types: -- -- -- -- These accessors are not shown in this API documentation. They have the -- same name as the field, but with the trailing underscore dropped. -- Hence for data field f_::F in type D, they have type -- --
-- f :: Data.Accessor.Accessor D F --module Graphics.Rendering.Chart.Pie data PieLayout PieLayout :: String -> CairoFontStyle -> PieChart -> CairoFillStyle -> Double -> PieLayout pie_title_ :: PieLayout -> String pie_title_style_ :: PieLayout -> CairoFontStyle pie_plot_ :: PieLayout -> PieChart pie_background_ :: PieLayout -> CairoFillStyle pie_margin_ :: PieLayout -> Double data PieChart PieChart :: [PieItem] -> [AlphaColour Double] -> CairoFontStyle -> CairoLineStyle -> Double -> PieChart pie_data_ :: PieChart -> [PieItem] pie_colors_ :: PieChart -> [AlphaColour Double] pie_label_style_ :: PieChart -> CairoFontStyle pie_label_line_style_ :: PieChart -> CairoLineStyle pie_start_angle_ :: PieChart -> Double data PieItem PieItem :: String -> Double -> Double -> PieItem pitem_label_ :: PieItem -> String pitem_offset_ :: PieItem -> Double pitem_value_ :: PieItem -> Double defaultPieLayout :: PieLayout defaultPieChart :: PieChart defaultPieItem :: PieItem pie_title :: T PieLayout String pie_title_style :: T PieLayout CairoFontStyle pie_plot :: T PieLayout PieChart pie_background :: T PieLayout CairoFillStyle pie_margin :: T PieLayout Double pie_data :: T PieChart ([] PieItem) pie_colors :: T PieChart ([] (AlphaColour Double)) pie_label_style :: T PieChart CairoFontStyle pie_label_line_style :: T PieChart CairoLineStyle pie_start_angle :: T PieChart Double pitem_label :: T PieItem String pitem_offset :: T PieItem Double pitem_value :: T PieItem Double instance ToRenderable PieChart instance ToRenderable PieLayout -- | A framework for creating 2D charts in Haskell. -- -- The basic model is that you define a value of type Renderable, -- typically by applying toRenderable to some other value. This -- Renderable is then actually displayed or output by calling -- either renderableToPNGFile, or -- Graphics.Rendering.Chart.Gtk.renderableToWindow. -- -- Currently, there are two kinds of Renderable for displaying -- charts: -- --
-- renderableToWindow (toRenderable $ plotLayout $ -- plot [0,0.1..10] sin "sin(x)") 640 480 ---- --
-- plotWindow [0,1,3,4,8] [12,15,1,5,8] "o" "points" ---- --
-- plotPDF "foo.pdf" [0,0.1..10] sin "- " cos ". " cos "o" ---- --
-- plotPS "foo.ps" [0,0.1..10] (sin . exp) "- " (sin . exp) "o-" --module Graphics.Rendering.Chart.Simple -- | The main plotting function. The idea behind PlotType is shamelessly -- copied from Text.Printf (and is not exported). All you need to know is -- that your arguments need to be in class PlotArg. And PlotArg consists -- of functions and [Double] and String and PlotKind or [PlotKind]. plot :: (PlotType a) => a -- | Type to define a few simple properties of each plot. data PlotKind Name :: String -> PlotKind FilledCircle :: PlotKind HollowCircle :: PlotKind Triangle :: PlotKind DownTriangle :: PlotKind Square :: PlotKind Diamond :: PlotKind Plus :: PlotKind Ex :: PlotKind Star :: PlotKind Symbols :: PlotKind LittleDot :: PlotKind Dashed :: PlotKind Dotted :: PlotKind Solid :: PlotKind xcoords :: [Double] -> UPlot -- | Display a plot on the screen. plotWindow :: (PlotWindowType a) => a -- | Save a plot as a PDF file. plotPDF :: (PlotPDFType a) => String -> a -- | Save a plot as a postscript file. plotPS :: (PlotPSType a) => String -> a plotLayout :: Layout1DDD -> Layout1 Double Double -- | Save a plot as a png file. plotPNG :: (PlotPNGType a) => String -> a data Layout1DDD instance Eq PlotKind instance Show PlotKind instance Ord PlotKind instance (IsPlot p, IsPlot q) => IsPlot (p, q) instance (IsPlot p, IsPlot q, IsPlot r) => IsPlot (p, q, r) instance (IsPlot p) => IsPlot [p] instance IsPlot Char instance IsPlot Double instance IsPlot PlotKind instance PlotArg PlotKind instance PlotArg UPlot instance (Real a, Real b, Fractional a, Fractional b) => IsPlot (a -> b) instance (Real a, Real b, Fractional a, Fractional b) => PlotArg (a -> b) instance (IsPlot p) => PlotArg [p] instance PlotPNGType (IO a) instance (PlotArg a, PlotPNGType r) => PlotPNGType (a -> r) instance PlotPSType (IO a) instance (PlotArg a, PlotPSType r) => PlotPSType (a -> r) instance PlotPDFType (IO a) instance (PlotArg a, PlotPDFType r) => PlotPDFType (a -> r) instance PlotWindowType (IO a) instance (PlotArg a, PlotWindowType r) => PlotWindowType (a -> r) instance PlotType Layout1DDD instance (PlotArg a, PlotType r) => PlotType (a -> r) instance ToRenderable Layout1DDD