-- 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 1.0 -- | Non chart specific utility functions. module Graphics.Rendering.Chart.Utils -- | Checks if the given value is and actual numeric value and not a -- concept like NaN or infinity. isValidNumber :: RealFloat a => a -> Bool -- | Version of maybe that returns a monadic value. maybeM :: Monad m => b -> (a -> m b) -> Maybe a -> m b module Graphics.Rendering.Chart.Geometry -- | 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 -- | A vector in two dimensions. data Vector Vector :: Double -> Double -> Vector v_x :: Vector -> Double v_y :: Vector -> Double type RectSize = (Double, Double) type Range = (Double, Double) -- | Convert a Point to a Vector. pointToVec :: Point -> Vector -- | Create a rectangle based upon the coordinates of 4 points. mkrect :: Point -> Point -> Point -> Point -> Rect -- | Make a path from a rectangle. rectPath :: Rect -> Path -- | 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 -- | Intersects the rectangles. If they intersect the intersection -- rectangle is returned. LMin is the empty rectangle / -- intersection and LMax is the infinite plane. intersectRect :: Limit Rect -> Limit Rect -> Limit Rect -- | Edge of a rectangle. 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 -- | The path type used by Charts. -- -- A path can consist of several subpaths. Each is started by a -- MoveTo operation. All subpaths are open, except the last one, -- which may be closed using the Close operation. When filling a -- path all subpaths are closed implicitly. -- -- Closing a subpath means that a line is drawn from the end point to the -- start point of the subpath. -- -- If a Arc (or ArcNeg) is drawn a implicit line from the -- last end point of the subpath is drawn to the beginning of the arc. -- Another implicit line is drawn from the end of an arc to the beginning -- of the next path segment. -- -- The beginning of a subpath is either (0,0) or set by a MoveTo -- instruction. If the first subpath is started with an arc the beginning -- of that subpath is the beginning of the arc. data Path MoveTo :: Point -> Path -> Path LineTo :: Point -> Path -> Path Arc :: Point -> Double -> Double -> Double -> Path -> Path ArcNeg :: Point -> Double -> Double -> Double -> Path -> Path End :: Path Close :: Path -- | Move the paths pointer to the given location and draw a straight line -- while doing so. lineTo :: Point -> Path -- | Move the paths pointer to the given location. moveTo :: Point -> Path -- | Short-cut for lineTo, if you don't want to create a -- Point. lineTo' :: Double -> Double -> Path -- | Short-cut for moveTo, if you don't want to create a -- Point. moveTo' :: Double -> Double -> Path -- | Draw the arc of a circle. A straight line connects the end of the -- previous path with the beginning of the arc. The zero angle points in -- direction of the positive x-axis. Angles increase in clock-wise -- direction. If the stop angle is smaller then the start angle it is -- increased by multiples of 2 * pi until is is greater or -- equal. arc :: Point -> Double -> Double -> Double -> Path -- | Short-cut for arc, if you don't want to create a Point. arc' :: Double -> Double -> Double -> Double -> Double -> Path -- | Like arc, but draws from the stop angle to the start angle -- instead of between them. arcNeg :: Point -> Double -> Double -> Double -> Path -- | Short-cut for arcNeg, if you don't want to create a -- Point. arcNeg' :: Double -> Double -> Double -> Double -> Double -> Path -- | A closed empty path. Closes a path when appended. close :: Path -- | Fold the given path to a monoid structure. foldPath :: Monoid m => (Point -> m) -> (Point -> m) -> (Point -> Double -> Double -> Double -> m) -> (Point -> Double -> Double -> Double -> m) -> m -> Path -> m -- | Enriches the path with explicit instructions to draw lines, that -- otherwise would be implicit. See Path for details about what -- lines in paths are implicit. makeLinesExplicit :: Path -> Path -- | Transform a point using the given matrix. transformP :: Matrix -> Point -> Point -- | Scale a point. scaleP :: Vector -> Point -> Point -- | Rotate a point around the origin. The angle is given in radians. rotateP :: Double -> Point -> Point -- | Translate a point. translateP :: Vector -> Point -> Point -- | Copied from Graphics.Rendering.Cairo.Matrix data Matrix Matrix :: !Double -> !Double -> !Double -> !Double -> !Double -> !Double -> Matrix xx :: Matrix -> !Double yx :: Matrix -> !Double xy :: Matrix -> !Double yy :: Matrix -> !Double x0 :: Matrix -> !Double y0 :: Matrix -> !Double -- | Copied from Graphics.Rendering.Cairo.Matrix identity :: Matrix -- | Copied from Graphics.Rendering.Cairo.Matrix Rotations angle is given -- in radians. rotate :: Double -> Matrix -> Matrix -- | Copied and adopted from Graphics.Rendering.Cairo.Matrix scale :: Vector -> Matrix -> Matrix -- | Copied and adopted from Graphics.Rendering.Cairo.Matrix translate :: Vector -> Matrix -> Matrix -- | Copied from Graphics.Rendering.Cairo.Matrix scalarMultiply :: Double -> Matrix -> Matrix -- | Copied from Graphics.Rendering.Cairo.Matrix adjoint :: Matrix -> Matrix -- | Copied from Graphics.Rendering.Cairo.Matrix invert :: Matrix -> Matrix instance Show Point instance Show Vector instance Show a => Show (Limit a) instance Show Rect instance Show Matrix instance Num Matrix instance Monoid Path module Graphics.Rendering.Chart.Backend.Types -- | The different supported line ends. data LineCap -- | Just cut the line straight. LineCapButt :: LineCap -- | Make a rounded line end. LineCapRound :: LineCap -- | Make a square that ends the line. LineCapSquare :: LineCap -- | The different supported ways to join line ends. data LineJoin -- | Extends the outline until they meet each other. LineJoinMiter :: LineJoin -- | Draw a circle fragment to connet line end. LineJoinRound :: LineJoin -- | Like miter, but cuts it off if a certain threshold is exceeded. LineJoinBevel :: LineJoin -- | Data type for the style of a line. data LineStyle LineStyle :: Double -> AlphaColour Double -> [Double] -> LineCap -> LineJoin -> LineStyle -- | The thickness of a line in device units. _line_width :: LineStyle -> Double -- | The color of a line. _line_color :: LineStyle -> AlphaColour Double -- | The dash pattern. Every value at a even index gives a dash width and -- every value at a odd index gives a gap width in device units. _line_dashes :: LineStyle -> [Double] -- | How to end a line. _line_cap :: LineStyle -> LineCap -- | How to connect two lines. _line_join :: LineStyle -> LineJoin -- | The possible slants of a font. data FontSlant -- | Normal font style without slant. FontSlantNormal :: FontSlant -- | With a slight slant. FontSlantItalic :: FontSlant -- | With a greater slant. FontSlantOblique :: FontSlant -- | The possible weights of a font. data FontWeight -- | Normal font style without weight. FontWeightNormal :: FontWeight -- | Bold font. FontWeightBold :: FontWeight -- | Data type for a font. data FontStyle FontStyle :: String -> Double -> FontSlant -> FontWeight -> AlphaColour Double -> FontStyle -- | The font family or font face to use. _font_name :: FontStyle -> String -- | The height of the rendered font in device coordinates. _font_size :: FontStyle -> Double -- | The slant to render with. _font_slant :: FontStyle -> FontSlant -- | The weight to render with. _font_weight :: FontStyle -> FontWeight -- | The color to render text with. _font_color :: FontStyle -> AlphaColour Double -- | The default font style. -- | Deprecated: Use the according Data.Default instance! defaultFontStyle :: FontStyle -- | Possible horizontal anchor points for text. data HTextAnchor HTA_Left :: HTextAnchor HTA_Centre :: HTextAnchor HTA_Right :: HTextAnchor -- | Possible vertical anchor points for text. data VTextAnchor VTA_Top :: VTextAnchor VTA_Centre :: VTextAnchor VTA_Bottom :: VTextAnchor VTA_BaseLine :: VTextAnchor -- | Text metrics returned by textSize. data TextSize TextSize :: Double -> Double -> Double -> Double -> Double -> TextSize -- | The total width of the text. textSizeWidth :: TextSize -> Double -- | The ascent or space above the baseline. textSizeAscent :: TextSize -> Double -- | The decent or space below the baseline. textSizeDescent :: TextSize -> Double -- | The Y bearing. textSizeYBearing :: TextSize -> Double -- | The total height of the text. textSizeHeight :: TextSize -> Double -- | Abstract data type for a fill style. -- -- The contained Cairo action sets the required fill style in the Cairo -- rendering state. newtype FillStyle FillStyleSolid :: AlphaColour Double -> FillStyle _fill_colour :: FillStyle -> AlphaColour Double -- | A function to align points for a certain rendering device. type AlignmentFn = Point -> Point -- | Holds the point and coordinate alignment function. data AlignmentFns AlignmentFns :: AlignmentFn -> AlignmentFn -> AlignmentFns -- | 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. -- -- This is usually used to align prior to stroking. afPointAlignFn :: AlignmentFns -> AlignmentFn -- | A adjustment applied immediately prior to coordinates being -- transformed. -- -- This is usually used to align prior to filling. afCoordAlignFn :: AlignmentFns -> AlignmentFn -- | Alignment to render good on raster based graphics. bitmapAlignmentFns :: AlignmentFns -- | Alignment to render good on vector based graphics. vectorAlignmentFns :: AlignmentFns line_width :: Lens' LineStyle Double line_join :: Lens' LineStyle LineJoin line_dashes :: Lens' LineStyle [Double] line_color :: Lens' LineStyle (AlphaColour Double) line_cap :: Lens' LineStyle LineCap font_weight :: Lens' FontStyle FontWeight font_slant :: Lens' FontStyle FontSlant font_size :: Lens' FontStyle Double font_name :: Lens' FontStyle String font_color :: Lens' FontStyle (AlphaColour Double) instance Show LineCap instance Eq LineCap instance Ord LineCap instance Show LineJoin instance Eq LineJoin instance Ord LineJoin instance Show LineStyle instance Eq LineStyle instance Show FontSlant instance Eq FontSlant instance Ord FontSlant instance Show FontWeight instance Eq FontWeight instance Ord FontWeight instance Show FontStyle instance Eq FontStyle instance Show HTextAnchor instance Eq HTextAnchor instance Ord HTextAnchor instance Show VTextAnchor instance Eq VTextAnchor instance Ord VTextAnchor instance Show TextSize instance Eq TextSize instance Show FillStyle instance Eq FillStyle instance Default FillStyle instance Default FontStyle instance Default FontWeight instance Default FontSlant instance Default LineStyle -- | This module provides the implementation details common to all -- ChartBackends. module Graphics.Rendering.Chart.Backend.Impl -- | The abstract drawing operation generated when using the the chart -- drawing API. -- -- See the documentation of the different function for the correct -- semantics of each instruction: -- -- data ChartBackendInstr a StrokePath :: Path -> ChartBackendInstr () FillPath :: Path -> ChartBackendInstr () GetTextSize :: String -> ChartBackendInstr TextSize DrawText :: Point -> String -> ChartBackendInstr () GetAlignments :: ChartBackendInstr AlignmentFns WithTransform :: Matrix -> Program ChartBackendInstr a -> ChartBackendInstr a WithFontStyle :: FontStyle -> Program ChartBackendInstr a -> ChartBackendInstr a WithFillStyle :: FillStyle -> Program ChartBackendInstr a -> ChartBackendInstr a WithLineStyle :: LineStyle -> Program ChartBackendInstr a -> ChartBackendInstr a WithClipRegion :: Rect -> Program ChartBackendInstr a -> ChartBackendInstr a -- | A ChartBackend provides the capability to render a chart -- somewhere. -- -- The coordinate system of the backend has its initial origin (0,0) in -- the top left corner of the drawing plane. The x-axis points towards -- the top right corner and the y-axis points towards the bottom left -- corner. The unit used by coordinates, the font size, and lengths is -- the always the same, but depends on the backend. All angles are -- measured in radians. -- -- The line, fill and font style are set to their default values -- initially. -- -- Information about the semantics of the instructions can be found in -- the documentation of ChartBackendInstr. type ChartBackend a = Program ChartBackendInstr a -- | Alias so the old name for rendering code still works. -- | Deprecated: Use the new name ChartBackend! type CRender a = ChartBackend a -- | Stroke the outline of the given path using the current -- LineStyle. This function does not perform alignment -- operations on the path. See Path for the exact semantic of -- paths. strokePath :: Path -> ChartBackend () -- | Fill the given path using the current FillStyle. The given path -- will be closed prior to filling. This function does not perform -- alignment operations on the path. See Path for the exact -- semantic of paths. fillPath :: Path -> ChartBackend () -- | Calculate a TextSize object with rendering information about -- the given string without actually rendering it. textSize :: String -> ChartBackend TextSize -- | Draw a single-line textual label anchored by the baseline (vertical) -- left (horizontal) point. Uses the current FontStyle for -- drawing. drawText :: Point -> String -> ChartBackend () -- | Apply the given transformation in this local environment when drawing. -- The given transformation is applied after the current transformation. -- This means both are combined. withTransform :: Matrix -> ChartBackend a -> ChartBackend a -- | Use the given font style in this local environment when drawing text. -- -- An implementing backend is expected to guarentee to support the -- following font families: serif, sans-serif and -- monospace; -- -- If the backend is not able to find or load a given font it is required -- to fall back to a custom fail-safe font and use it instead. withFontStyle :: FontStyle -> ChartBackend a -> ChartBackend a -- | Use the given fill style in this local environment when filling paths. withFillStyle :: FillStyle -> ChartBackend a -> ChartBackend a -- | Use the given line style in this local environment when stroking -- paths. withLineStyle :: LineStyle -> ChartBackend a -> ChartBackend a -- | Use the given clipping rectangle when drawing in this local -- environment. The new clipping region is intersected with the given -- clip region. You cannot escape the clip! withClipRegion :: Rect -> ChartBackend a -> ChartBackend a -- | Get the point alignment function getPointAlignFn :: ChartBackend (Point -> Point) -- | Get the coordinate alignment function getCoordAlignFn :: ChartBackend (Point -> Point) -- | This module provides the API for drawing operations abstracted to -- arbitrary ChartBackends. module Graphics.Rendering.Chart.Backend -- | A ChartBackend provides the capability to render a chart -- somewhere. -- -- The coordinate system of the backend has its initial origin (0,0) in -- the top left corner of the drawing plane. The x-axis points towards -- the top right corner and the y-axis points towards the bottom left -- corner. The unit used by coordinates, the font size, and lengths is -- the always the same, but depends on the backend. All angles are -- measured in radians. -- -- The line, fill and font style are set to their default values -- initially. -- -- Information about the semantics of the instructions can be found in -- the documentation of ChartBackendInstr. type ChartBackend a = Program ChartBackendInstr a -- | Alias so the old name for rendering code still works. -- | Deprecated: Use the new name ChartBackend! type CRender a = ChartBackend a -- | Fill the given path using the current FillStyle. The given path -- will be closed prior to filling. This function does not perform -- alignment operations on the path. See Path for the exact -- semantic of paths. fillPath :: Path -> ChartBackend () -- | Stroke the outline of the given path using the current -- LineStyle. This function does not perform alignment -- operations on the path. See Path for the exact semantic of -- paths. strokePath :: Path -> ChartBackend () -- | Draw a single-line textual label anchored by the baseline (vertical) -- left (horizontal) point. Uses the current FontStyle for -- drawing. drawText :: Point -> String -> ChartBackend () -- | Calculate a TextSize object with rendering information about -- the given string without actually rendering it. textSize :: String -> ChartBackend TextSize -- | Apply the given transformation in this local environment when drawing. -- The given transformation is applied after the current transformation. -- This means both are combined. withTransform :: Matrix -> ChartBackend a -> ChartBackend a -- | Use the given clipping rectangle when drawing in this local -- environment. The new clipping region is intersected with the given -- clip region. You cannot escape the clip! withClipRegion :: Rect -> ChartBackend a -> ChartBackend a -- | Use the given font style in this local environment when drawing text. -- -- An implementing backend is expected to guarentee to support the -- following font families: serif, sans-serif and -- monospace; -- -- If the backend is not able to find or load a given font it is required -- to fall back to a custom fail-safe font and use it instead. withFontStyle :: FontStyle -> ChartBackend a -> ChartBackend a -- | Use the given fill style in this local environment when filling paths. withFillStyle :: FillStyle -> ChartBackend a -> ChartBackend a -- | Use the given line style in this local environment when stroking -- paths. withLineStyle :: LineStyle -> ChartBackend a -> ChartBackend a -- | Get the point alignment function getPointAlignFn :: ChartBackend (Point -> Point) -- | Get the coordinate alignment function getCoordAlignFn :: ChartBackend (Point -> Point) -- | Text metrics returned by textSize. data TextSize TextSize :: Double -> Double -> Double -> Double -> Double -> TextSize -- | The total width of the text. textSizeWidth :: TextSize -> Double -- | The ascent or space above the baseline. textSizeAscent :: TextSize -> Double -- | The decent or space below the baseline. textSizeDescent :: TextSize -> Double -- | The Y bearing. textSizeYBearing :: TextSize -> Double -- | The total height of the text. textSizeHeight :: TextSize -> Double -- | The different supported line ends. data LineCap -- | Just cut the line straight. LineCapButt :: LineCap -- | Make a rounded line end. LineCapRound :: LineCap -- | Make a square that ends the line. LineCapSquare :: LineCap -- | The different supported ways to join line ends. data LineJoin -- | Extends the outline until they meet each other. LineJoinMiter :: LineJoin -- | Draw a circle fragment to connet line end. LineJoinRound :: LineJoin -- | Like miter, but cuts it off if a certain threshold is exceeded. LineJoinBevel :: LineJoin -- | Data type for the style of a line. data LineStyle LineStyle :: Double -> AlphaColour Double -> [Double] -> LineCap -> LineJoin -> LineStyle -- | The thickness of a line in device units. _line_width :: LineStyle -> Double -- | The color of a line. _line_color :: LineStyle -> AlphaColour Double -- | The dash pattern. Every value at a even index gives a dash width and -- every value at a odd index gives a gap width in device units. _line_dashes :: LineStyle -> [Double] -- | How to end a line. _line_cap :: LineStyle -> LineCap -- | How to connect two lines. _line_join :: LineStyle -> LineJoin line_width :: Lens' LineStyle Double line_color :: Lens' LineStyle (AlphaColour Double) line_dashes :: Lens' LineStyle [Double] line_cap :: Lens' LineStyle LineCap line_join :: Lens' LineStyle LineJoin -- | Abstract data type for a fill style. -- -- The contained Cairo action sets the required fill style in the Cairo -- rendering state. newtype FillStyle FillStyleSolid :: AlphaColour Double -> FillStyle _fill_colour :: FillStyle -> AlphaColour Double -- | The possible weights of a font. data FontWeight -- | Normal font style without weight. FontWeightNormal :: FontWeight -- | Bold font. FontWeightBold :: FontWeight -- | The possible slants of a font. data FontSlant -- | Normal font style without slant. FontSlantNormal :: FontSlant -- | With a slight slant. FontSlantItalic :: FontSlant -- | With a greater slant. FontSlantOblique :: FontSlant -- | Data type for a font. data FontStyle FontStyle :: String -> Double -> FontSlant -> FontWeight -> AlphaColour Double -> FontStyle -- | The font family or font face to use. _font_name :: FontStyle -> String -- | The height of the rendered font in device coordinates. _font_size :: FontStyle -> Double -- | The slant to render with. _font_slant :: FontStyle -> FontSlant -- | The weight to render with. _font_weight :: FontStyle -> FontWeight -- | The color to render text with. _font_color :: FontStyle -> AlphaColour Double -- | The default font style. -- | Deprecated: Use the according Data.Default instance! defaultFontStyle :: FontStyle -- | Possible horizontal anchor points for text. data HTextAnchor HTA_Left :: HTextAnchor HTA_Centre :: HTextAnchor HTA_Right :: HTextAnchor -- | Possible vertical anchor points for text. data VTextAnchor VTA_Top :: VTextAnchor VTA_Centre :: VTextAnchor VTA_Bottom :: VTextAnchor VTA_BaseLine :: VTextAnchor font_name :: Lens' FontStyle String font_size :: Lens' FontStyle Double font_slant :: Lens' FontStyle FontSlant font_weight :: Lens' FontStyle FontWeight font_color :: Lens' FontStyle (AlphaColour Double) -- | A function to align points for a certain rendering device. type AlignmentFn = Point -> Point -- | Holds the point and coordinate alignment function. data AlignmentFns -- | Alignment to render good on vector based graphics. vectorAlignmentFns :: AlignmentFns -- | Alignment to render good on raster based graphics. bitmapAlignmentFns :: AlignmentFns -- | This module contains basic types and functions used for drawing. -- -- Note that Template Haskell is used to derive accessor functions (see -- Lens) 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 :: Control.Lens.Lens' D F
--   
module Graphics.Rendering.Chart.Drawing -- | The different shapes a point can have. data PointShape -- | A circle. PointShapeCircle :: PointShape -- | Number of vertices and is right-side-up? PointShapePolygon :: Int -> Bool -> PointShape -- | A plus sign. PointShapePlus :: PointShape -- | A cross. PointShapeCross :: PointShape -- | Combination of a cross and a plus. PointShapeStar :: PointShape -- | 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. data PointStyle PointStyle :: AlphaColour Double -> AlphaColour Double -> Double -> Double -> PointShape -> PointStyle -- | The color to fill the point with. _point_color :: PointStyle -> AlphaColour Double -- | The color to stroke the outline with. _point_border_color :: PointStyle -> AlphaColour Double -- | The width of the outline. _point_border_width :: PointStyle -> Double -- | The radius of the tightest surrounding circle of the point. _point_radius :: PointStyle -> Double -- | The shape. _point_shape :: PointStyle -> PointShape -- | Draw a single point at the given location. drawPoint :: PointStyle -> Point -> ChartBackend () -- | Default style for points. -- | Deprecated: Use the according Data.Default instance! defaultPointStyle :: PointStyle -- | Align the path by applying the given function on all points. alignPath :: (Point -> Point) -> Path -> Path -- | Align the path using the environment's alignment function for -- coordinates. This is generally useful when filling. See -- alignPath and getCoordAlignFn. alignFillPath :: Path -> ChartBackend Path -- | Align the path using the environment's alignment function for points. -- This is generally useful when stroking. See alignPath and -- getPointAlignFn. alignStrokePath :: Path -> ChartBackend Path -- | The points will be aligned by the getCoordAlignFn, so that when -- drawing bitmaps, the edges of the region will fall between pixels. alignFillPoints :: [Point] -> ChartBackend [Point] -- | The points will be aligned by the getPointAlignFn, so that when -- drawing bitmaps, 1 pixel wide lines will be centred on the pixels. alignStrokePoints :: [Point] -> ChartBackend [Point] -- | Align the point using the environment's alignment function for -- coordinates. See getCoordAlignFn. alignFillPoint :: Point -> ChartBackend Point -- | Align the point using the environment's alignment function for points. -- See getPointAlignFn. alignStrokePoint :: Point -> ChartBackend Point -- | Draw lines between the specified points. strokePointPath :: [Point] -> ChartBackend () -- | Fill the region with the given corners. fillPointPath :: [Point] -> ChartBackend () -- | Apply a local rotation. The angle is given in radians. withRotation :: Double -> ChartBackend a -> ChartBackend a -- | Apply a local translation. withTranslation :: Point -> ChartBackend a -> ChartBackend a -- | Apply a local scale. withScale :: Vector -> ChartBackend a -> ChartBackend a -- | Apply a local scale on the x-axis. withScaleX :: Double -> ChartBackend a -> ChartBackend a -- | Apply a local scale on the y-axis. withScaleY :: Double -> ChartBackend a -> ChartBackend a -- | Changes the LineStyle and FillStyle to comply with the -- given PointStyle. withPointStyle :: PointStyle -> ChartBackend a -> ChartBackend a withDefaultStyle :: ChartBackend a -> ChartBackend a -- | Draw a line of text that is aligned at a different anchor point. See -- drawText. drawTextA :: HTextAnchor -> VTextAnchor -> Point -> String -> ChartBackend () -- | 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. See drawText. drawTextR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> ChartBackend () -- | Draw a multi-line textual label anchored by one of its corners or -- edges, with rotation. Rotation angle is given in degrees, rotation is -- performed around anchor point. See drawText. drawTextsR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> ChartBackend () -- | Return the bounding rectangle for a text string positioned where it -- would be drawn by drawText. See textSize. textDrawRect :: HTextAnchor -> VTextAnchor -> Point -> String -> ChartBackend Rect -- | Get the width and height of the string when rendered. See -- textSize. textDimension :: String -> ChartBackend RectSize -- | The default sequence of colours to use when plotings different data -- sets in a graph. defaultColorSeq :: [AlphaColour Double] -- | Create a solid line style (not dashed). solidLine :: Double -> AlphaColour Double -> LineStyle -- | Create a dashed line style. dashedLine :: Double -> [Double] -> AlphaColour Double -> LineStyle -- | Style for filled circle points. filledCircles :: Double -> AlphaColour Double -> PointStyle -- | Style for stroked circle points. hollowCircles :: Double -> Double -> AlphaColour Double -> PointStyle -- | Style for filled polygon points. filledPolygon :: Double -> Int -> Bool -> AlphaColour Double -> PointStyle -- | Style for stroked polygon points. hollowPolygon :: Double -> Double -> Int -> Bool -> AlphaColour Double -> PointStyle -- | Plus sign point style. plusses :: Double -> Double -> AlphaColour Double -> PointStyle -- | Cross point style. exes :: Double -> Double -> AlphaColour Double -> PointStyle -- | Combination of plus and cross point style. stars :: Double -> Double -> AlphaColour Double -> PointStyle -- | Fill style that fill everything this the given colour. solidFillStyle :: AlphaColour Double -> FillStyle instance Default PointStyle -- | 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 :: ChartBackend RectSize -> (RectSize -> ChartBackend (PickFn a)) -> Renderable a -- | A Cairo action to calculate a minimum size. minsize :: Renderable a -> ChartBackend 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 -> ChartBackend (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) rectangleToRenderable :: Rectangle -> Renderable a -- | Overlay a renderable over a solid background fill. fillBackground :: FillStyle -> 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 :: ChartBackend (Renderable a) -> Renderable a -- | Construct a renderable from a text string, aligned with the axes. label :: FontStyle -> HTextAnchor -> VTextAnchor -> String -> Renderable String -- | Construct a renderable from a text string, rotated wrt to axes. The -- angle of rotation is in degrees. rlabel :: FontStyle -> HTextAnchor -> VTextAnchor -> Double -> String -> Renderable String -- | 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 the result of a renderable's pickfunction, keeping -- only Just results. mapMaybePickFn :: (a -> Maybe 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 rect_minsize :: Lens' Rectangle RectSize rect_fillStyle :: Lens' Rectangle (Maybe FillStyle) rect_lineStyle :: Lens' Rectangle (Maybe LineStyle) rect_cornerStyle :: Lens' Rectangle RectCornerStyle instance ToRenderable Rectangle instance Default Rectangle -- | Type definitions for Axes module Graphics.Rendering.Chart.Axis.Types -- | The basic data associated with an axis showing values of type x. data AxisData x AxisData :: (Range -> x -> Double) -> (Range -> Double -> x) -> [(x, Double)] -> [[(x, String)]] -> [x] -> AxisData x -- | The _axis_viewport function maps values into device coordinates. _axis_viewport :: AxisData x -> Range -> x -> Double -- | The _axis_tropweiv function maps device coordinates back to values. _axis_tropweiv :: AxisData x -> Range -> Double -> x -- | 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 of the pair is the -- position on the axis (in viewport units) and the second is the label -- text string. Note that multiple sets of labels can be specified, and -- are shown successively further away from the axis line. _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 -- | Control values for how an axis gets displayed. data AxisStyle AxisStyle :: LineStyle -> FontStyle -> LineStyle -> Double -> AxisStyle _axis_line_style :: AxisStyle -> LineStyle _axis_label_style :: AxisStyle -> FontStyle _axis_grid_style :: AxisStyle -> LineStyle -- | How far the labels are to be drawn from the axis. _axis_label_gap :: AxisStyle -> Double -- | A typeclass abstracting the functions we need to be able to plot -- against an axis of type a class Ord a => PlotValue a toValue :: PlotValue a => a -> Double fromValue :: PlotValue a => Double -> a autoAxis :: PlotValue a => AxisFn a -- | A function to generate the axis data, given the data values to be -- plotted against it. type AxisFn x = [x] -> AxisData x defaultAxisLineStyle :: LineStyle -- | Deprecated: Use the according Data.Default instance! defaultAxisStyle :: AxisStyle defaultGridLineStyle :: LineStyle -- | Construct an axis given the positions for ticks, grid lines, and -- labels, and the labelling function makeAxis :: PlotValue x => (x -> String) -> ([x], [x], [x]) -> AxisData x -- | Construct an axis given the positions for ticks, grid lines, and -- labels, and the positioning and labelling functions makeAxis' :: Ord x => (x -> Double) -> (Double -> x) -> (x -> String) -> ([x], [x], [x]) -> AxisData x -- | Construct a renderable from an axis, in order that it can be composed -- with other renderables and drawn. This does not include the drawing of -- the grid, which must be done separately by the renderAxisGrid -- function. axisToRenderable :: AxisT x -> Renderable x renderAxisGrid :: RectSize -> AxisT z -> ChartBackend () -- | Calculate the amount by which the labels extend beyond the ends of the -- axis. axisOverhang :: Ord x => AxisT x -> ChartBackend (Double, Double) -- | A linear mapping of points in one range to another. vmap :: PlotValue x => (x, x) -> Range -> x -> Double -- | The inverse mapping from device co-ordinate range back to interesting -- values. invmap :: PlotValue x => (x, x) -> Range -> Double -> x -- | A linear mapping of points in one range to another. linMap :: (a -> Double) -> (a, a) -> Range -> a -> Double -- | An inverse linear mapping of points from one range to another. invLinMap :: (Double -> a) -> (a -> Double) -> (a, a) -> Range -> Double -> a -- | Modifier to position grid lines to line up with the ticks axisGridAtTicks :: AxisData x -> AxisData x -- | Modifier to position grid lines to line up with only the major ticks axisGridAtBigTicks :: AxisData x -> AxisData x -- | Modifier to position grid lines to line up with the labels axisGridAtLabels :: AxisData x -> AxisData x -- | Modifier to remove grid lines from an axis axisGridHide :: AxisData x -> AxisData x -- | Modifier to remove ticks from an axis axisTicksHide :: AxisData x -> AxisData x -- | Modifier to remove labels from an axis axisLabelsHide :: AxisData x -> AxisData x -- | Modifier to change labels on an axis axisLabelsOverride :: [(x, String)] -> AxisData x -> AxisData x axis_viewport :: Lens' (AxisData x_amXb) (Range -> x_amXb -> Double) axis_tropweiv :: Lens' (AxisData x_amXb) (Range -> Double -> x_amXb) axis_ticks :: Lens' (AxisData x_amXb) [(x_amXb, Double)] axis_labels :: Lens' (AxisData x_amXb) [[(x_amXb, String)]] axis_grid :: Lens' (AxisData x_amXb) [x_amXb] axis_line_style :: Lens' AxisStyle LineStyle axis_label_style :: Lens' AxisStyle FontStyle axis_grid_style :: Lens' AxisStyle LineStyle axis_label_gap :: Lens' AxisStyle Double instance Default AxisStyle -- | Calculate and render unit indexed axes module Graphics.Rendering.Chart.Axis.Unit unitAxis :: AxisData () instance PlotValue () -- | Calculate and render indexed axes module Graphics.Rendering.Chart.Axis.Indexed -- | 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 -- | 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)] instance Eq PlotIndex instance Ord PlotIndex instance Enum PlotIndex instance Num PlotIndex instance Real PlotIndex instance Integral PlotIndex instance Show PlotIndex instance PlotValue PlotIndex -- | Calculate and render floating value axes including doubles with -- linear, log, and percentage scaling. module Graphics.Rendering.Chart.Axis.Floating -- | A wrapper class for doubles used to indicate they are to be plotted -- against a percentage axis. newtype Percent Percent :: Double -> Percent unPercent :: Percent -> Double 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 -- | A wrapper class for doubles used to indicate they are to be plotted -- against a log axis. newtype LogValue LogValue :: Double -> LogValue data LogAxisParams a LogAxisParams :: (a -> String) -> LogAxisParams a -- | The function used to show the axes labels. _loga_labelf :: LogAxisParams a -> a -> String -- | Deprecated: Use the according Data.Default instance! defaultLinearAxis :: (Show a, RealFloat a) => LinearAxisParams a -- | Deprecated: Use the according Data.Default instance! defaultLogAxis :: (Show a, RealFloat a) => LogAxisParams a -- | Generate a linear axis with the specified bounds scaledAxis :: RealFloat a => LinearAxisParams a -> (a, a) -> AxisFn a -- | Generate a linear axis automatically, scaled appropriately for the -- input data. autoScaledAxis :: RealFloat a => LinearAxisParams a -> AxisFn a -- | Generate a log axis automatically, scaled appropriate for the input -- data. autoScaledLogAxis :: RealFloat a => LogAxisParams a -> AxisFn 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] la_labelf :: Lens (LinearAxisParams a_aur6) (LinearAxisParams a_auO0) (a_aur6 -> String) (a_auO0 -> String) la_nLabels :: Lens' (LinearAxisParams a_aur6) Int la_nTicks :: Lens' (LinearAxisParams a_aur6) Int loga_labelf :: Iso (LogAxisParams a_aur5) (LogAxisParams a_auOI) (a_aur5 -> String) (a_auOI -> String) instance Eq Percent instance Ord Percent instance Num Percent instance Real Percent instance Fractional Percent instance RealFrac Percent instance Floating Percent instance RealFloat Percent 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 (Show a, RealFloat a) => Default (LogAxisParams a) instance (Show a, RealFloat a) => Default (LinearAxisParams a) instance PlotValue LogValue instance Show LogValue instance PlotValue Percent instance Show Percent instance PlotValue Double -- | Calculate and render integer indexed axes module Graphics.Rendering.Chart.Axis.Int defaultIntAxis :: Show a => LinearAxisParams a scaledIntAxis :: (Integral i, PlotValue i) => LinearAxisParams i -> (i, i) -> AxisFn i autoScaledIntAxis :: (Integral i, PlotValue i) => LinearAxisParams i -> AxisFn i instance PlotValue Integer instance PlotValue Int -- | Calculate and render time axes module Graphics.Rendering.Chart.Axis.LocalTime -- | 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 -- third TimeSeq sets the second line of labels. 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 -> TimeLabelAlignment -> TimeSeq -> TimeLabelFn -> TimeLabelAlignment -> 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 instance Show TimeLabelAlignment instance PlotValue LocalTime -- | Code to calculate and render axes. module Graphics.Rendering.Chart.Axis -- | A container type for values that can be composed by horizonal and -- vertical layout. 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 below the grid, occupying 1 row with the same -- horizontal span as the grid. aboveWide :: Grid a -> a -> Grid a -- | A value occupying 1 row with the same horizontal span as the grid. wideAbove :: a -> Grid a -> Grid a -- | A value placed to the left of the grid, occupying 1 column with the -- same vertical span as the grid. tallBeside :: a -> Grid a -> Grid a -- | A value placed to the right of the grid, occupying 1 column with the -- same vertical span as the grid. besideTall :: Grid a -> 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 -- | Datatypes and functions common to the implementation of the various -- plot types. module Graphics.Rendering.Chart.Plot.Types -- | Interface to control plotting on a 2D area. data Plot x y Plot :: (PointMapFn x y -> ChartBackend ()) -> [(String, Rect -> ChartBackend ())] -> ([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 -> ChartBackend () -- | 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 -> ChartBackend ())] -- | 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 mapXY :: PointMapFn x y -> ((x, y) -> Point) plot_render :: Lens' (Plot x_aWhb y_aWhc) (PointMapFn x_aWhb y_aWhc -> ChartBackend ()) plot_legend :: Lens' (Plot x_aWhb y_aWhc) [(String, Rect -> ChartBackend ())] plot_all_points :: Lens' (Plot x_aWhb y_aWhc) ([x_aWhb], [y_aWhc]) -- | Types and functions for handling the legend(s) on a chart. A legend is -- an area on the chart used to label the plotted values. module Graphics.Rendering.Chart.Legend data Legend x y Legend :: LegendStyle -> [(String, Rect -> ChartBackend ())] -> Legend x y data LegendStyle LegendStyle :: FontStyle -> Double -> Double -> LegendOrientation -> LegendStyle _legend_label_style :: LegendStyle -> FontStyle _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 -- | Deprecated: Use the according Data.Default instance! defaultLegendStyle :: LegendStyle legendToRenderable :: Legend x y -> Renderable String legend_label_style :: Lens' LegendStyle FontStyle legend_margin :: Lens' LegendStyle Double legend_plot_size :: Lens' LegendStyle Double legend_orientation :: Lens' LegendStyle LegendOrientation instance Default LegendStyle instance ToRenderable (Legend x y) -- | Line plots module Graphics.Rendering.Chart.Plot.Lines -- | Value defining a series of (possibly disjointed) lines, and a style in -- which to render them. data PlotLines x y PlotLines :: String -> LineStyle -> [[(x, y)]] -> [[(Limit x, Limit y)]] -> PlotLines x y _plot_lines_title :: PlotLines x y -> String _plot_lines_style :: PlotLines x y -> LineStyle -- | The lines to be plotted _plot_lines_values :: PlotLines x y -> [[(x, y)]] -- | Additional lines to be plotted, specified using the Limit type to -- allow referencing the edges of the plot area. _plot_lines_limit_values :: PlotLines x y -> [[(Limit x, Limit y)]] -- | Deprecated: Use the according Data.Default instance! defaultPlotLines :: PlotLines x y defaultPlotLineStyle :: LineStyle -- | Helper function to plot a single horizontal line. hlinePlot :: String -> LineStyle -> b -> Plot a b -- | Helper function to plot a single vertical line. vlinePlot :: String -> LineStyle -> a -> Plot a b plot_lines_title :: Lens' (PlotLines x_aXuf y_aXug) String plot_lines_style :: Lens' (PlotLines x_aXuf y_aXug) LineStyle plot_lines_values :: Lens' (PlotLines x_aXuf y_aXug) [[(x_aXuf, y_aXug)]] plot_lines_limit_values :: Lens' (PlotLines x_aXuf y_aXug) [[(Limit x_aXuf, Limit y_aXug)]] instance Default (PlotLines x y) instance ToPlot PlotLines -- | Functions to plot sets of points, marked in various styles. module Graphics.Rendering.Chart.Plot.Points -- | Value defining a series of datapoints, and a style in which to render -- them. data PlotPoints x y PlotPoints :: String -> PointStyle -> [(x, y)] -> PlotPoints x y _plot_points_title :: PlotPoints x y -> String _plot_points_style :: PlotPoints x y -> PointStyle _plot_points_values :: PlotPoints x y -> [(x, y)] -- | Deprecated: Use the according Data.Default instance! defaultPlotPoints :: PlotPoints x y plot_points_title :: Lens' (PlotPoints x_aYjS y_aYjT) String plot_points_style :: Lens' (PlotPoints x_aYjS y_aYjT) PointStyle plot_points_values :: Lens (PlotPoints x_aYjS y_aYjT) (PlotPoints x_aYlv y_aYlw) [(x_aYjS, y_aYjT)] [(x_aYlv, y_aYlw)] instance Default (PlotPoints x y) instance ToPlot PlotPoints -- | Plots that fill the area between two lines. module Graphics.Rendering.Chart.Plot.FillBetween -- | Value specifying a plot filling the area between two sets of Y -- coordinates, given common X coordinates. data PlotFillBetween x y PlotFillBetween :: String -> FillStyle -> [(x, (y, y))] -> PlotFillBetween x y _plot_fillbetween_title :: PlotFillBetween x y -> String _plot_fillbetween_style :: PlotFillBetween x y -> FillStyle _plot_fillbetween_values :: PlotFillBetween x y -> [(x, (y, y))] -- | Deprecated: Use the according Data.Default instance! defaultPlotFillBetween :: PlotFillBetween x y plot_fillbetween_title :: Lens' (PlotFillBetween x_aYTN y_aYTO) String plot_fillbetween_style :: Lens' (PlotFillBetween x_aYTN y_aYTO) FillStyle plot_fillbetween_values :: Lens (PlotFillBetween x_aYTN y_aYTO) (PlotFillBetween x_aYW2 y_aYW3) [(x_aYTN, (y_aYTO, y_aYTO))] [(x_aYW2, (y_aYW3, y_aYW3))] instance Default (PlotFillBetween x y) instance ToPlot PlotFillBetween -- | Plot series of points with associated error bars. module Graphics.Rendering.Chart.Plot.ErrBars -- | Value defining a series of error intervals, and a style in which to -- render them. data PlotErrBars x y PlotErrBars :: String -> LineStyle -> Double -> Double -> [ErrPoint x y] -> PlotErrBars x y _plot_errbars_title :: PlotErrBars x y -> String _plot_errbars_line_style :: PlotErrBars x y -> LineStyle _plot_errbars_tick_length :: PlotErrBars x y -> Double _plot_errbars_overhang :: PlotErrBars x y -> Double _plot_errbars_values :: PlotErrBars x y -> [ErrPoint x y] -- | Deprecated: Use the according Data.Default instance! 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 plot_errbars_title :: Lens' (PlotErrBars x_aZCZ y_aZD0) String plot_errbars_line_style :: Lens' (PlotErrBars x_aZCZ y_aZD0) LineStyle plot_errbars_tick_length :: Lens' (PlotErrBars x_aZCZ y_aZD0) Double plot_errbars_overhang :: Lens' (PlotErrBars x_aZCZ y_aZD0) Double plot_errbars_values :: Lens (PlotErrBars x_aZCZ y_aZD0) (PlotErrBars x_aZIF y_aZIG) [ErrPoint x_aZCZ y_aZD0] [ErrPoint x_aZIF y_aZIG] instance Show x => Show (ErrValue x) instance (Show x, Show y) => Show (ErrPoint x y) instance Default (PlotErrBars x y) instance ToPlot PlotErrBars -- | Candlestick charts for financial plotting module Graphics.Rendering.Chart.Plot.Candle -- | Value defining a financial interval: opening and closing prices, with -- maxima and minima; and a style in which to render them. By convention, -- there are different fill styles depending on whether the price rises -- (open < close) or falls (close < open). (This plot type can also -- be re-purposed for statistical intervals, e.g. minimum, first -- quartile, median, third quartile, maximum.) data PlotCandle x y PlotCandle :: String -> LineStyle -> Bool -> FillStyle -> FillStyle -> Double -> Double -> Double -> [Candle x y] -> PlotCandle x y _plot_candle_title :: PlotCandle x y -> String _plot_candle_line_style :: PlotCandle x y -> LineStyle _plot_candle_fill :: PlotCandle x y -> Bool _plot_candle_rise_fill_style :: PlotCandle x y -> FillStyle _plot_candle_fall_fill_style :: PlotCandle x y -> FillStyle _plot_candle_tick_length :: PlotCandle x y -> Double _plot_candle_width :: PlotCandle x y -> Double _plot_candle_centre :: PlotCandle x y -> Double _plot_candle_values :: PlotCandle x y -> [Candle x y] -- | A Value holding price intervals for a given x-coord. An alternative -- view is that these are statistical intervals: the 0th, 25th, 50th, -- 75th, and 100th percentiles. data Candle x y Candle :: x -> y -> y -> y -> y -> y -> Candle x y candle_x :: Candle x y -> x candle_low :: Candle x y -> y candle_open :: Candle x y -> y candle_mid :: Candle x y -> y candle_close :: Candle x y -> y candle_high :: Candle x y -> y -- | Deprecated: Use the according Data.Default instance! defaultPlotCandle :: PlotCandle x y plot_candle_title :: Lens' (PlotCandle x_a11Ks y_a11Kt) String plot_candle_line_style :: Lens' (PlotCandle x_a11Ks y_a11Kt) LineStyle plot_candle_tick_length :: Lens' (PlotCandle x_a11Ks y_a11Kt) Double plot_candle_width :: Lens' (PlotCandle x_a11Ks y_a11Kt) Double plot_candle_centre :: Lens' (PlotCandle x_a11Ks y_a11Kt) Double plot_candle_fill :: Lens' (PlotCandle x_a11Ks y_a11Kt) Bool plot_candle_rise_fill_style :: Lens' (PlotCandle x_a11Ks y_a11Kt) FillStyle plot_candle_fall_fill_style :: Lens' (PlotCandle x_a11Ks y_a11Kt) FillStyle plot_candle_values :: Lens (PlotCandle x_a11Ks y_a11Kt) (PlotCandle x_a11QT y_a11QU) [Candle x_a11Ks y_a11Kt] [Candle x_a11QT y_a11QU] instance (Show x, Show y) => Show (Candle x y) instance Default (PlotCandle x y) instance ToPlot PlotCandle -- | Bar Charts module Graphics.Rendering.Chart.Plot.Bars -- | 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 -> [(FillStyle, Maybe LineStyle)] -> [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 -> [(FillStyle, Maybe LineStyle)] -- | 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])] -- | Deprecated: Use the according Data.Default instance! 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 plotBars :: BarsPlotValue y => PlotBars x y -> Plot x y plot_bars_style :: Lens' (PlotBars x_a14ak y_a14al) PlotBarsStyle plot_bars_item_styles :: Lens' (PlotBars x_a14ak y_a14al) [(FillStyle, Maybe LineStyle)] plot_bars_titles :: Lens' (PlotBars x_a14ak y_a14al) [String] plot_bars_spacing :: Lens' (PlotBars x_a14ak y_a14al) PlotBarsSpacing plot_bars_alignment :: Lens' (PlotBars x_a14ak y_a14al) PlotBarsAlignment plot_bars_reference :: Lens' (PlotBars x_a14ak y_a14al) y_a14al plot_bars_singleton_width :: Lens' (PlotBars x_a14ak y_a14al) Double plot_bars_values :: Lens (PlotBars x_a14ak y_a14al) (PlotBars x_a14ix y_a14al) [(x_a14ak, [y_a14al])] [(x_a14ix, [y_a14al])] instance Show PlotBarsStyle instance Show PlotBarsSpacing instance Show PlotBarsAlignment instance BarsPlotValue y => Default (PlotBars x y) instance BarsPlotValue Int instance BarsPlotValue Double -- | Plots that don't show, but occupy space so as to effect axis scaling module Graphics.Rendering.Chart.Plot.Hidden -- | 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] instance ToPlot PlotHidden -- | Show textual annotations on a chart. module Graphics.Rendering.Chart.Plot.Annotation -- | 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 -> FontStyle -> [(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 -> FontStyle _plot_annotation_values :: PlotAnnotation x y -> [(x, y, String)] -- | Deprecated: Use the according Data.Default instance! defaultPlotAnnotation :: PlotAnnotation x y plot_annotation_hanchor :: Lens' (PlotAnnotation x_a16VE y_a16VF) HTextAnchor plot_annotation_vanchor :: Lens' (PlotAnnotation x_a16VE y_a16VF) VTextAnchor plot_annotation_angle :: Lens' (PlotAnnotation x_a16VE y_a16VF) Double plot_annotation_style :: Lens' (PlotAnnotation x_a16VE y_a16VF) FontStyle plot_annotation_values :: Lens (PlotAnnotation x_a16VE y_a16VF) (PlotAnnotation x_a16Xv y_a16Xw) [(x_a16VE, y_a16VF, String)] [(x_a16Xv, y_a16Xw, String)] instance Default (PlotAnnotation x y) instance ToPlot PlotAnnotation -- | 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.Plot.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 -> Colour Double -> 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 -> Colour Double _area_spots_opacity :: AreaSpots z x y -> 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)] -- | Deprecated: Use the according Data.Default instance! defaultAreaSpots :: AreaSpots z x y area_spots_title :: Lens' (AreaSpots z_a17qB x_a17qC y_a17qD) String area_spots_linethick :: Lens' (AreaSpots z_a17qB x_a17qC y_a17qD) Double area_spots_linecolour :: Lens' (AreaSpots z_a17qB x_a17qC y_a17qD) (AlphaColour Double) area_spots_fillcolour :: Lens' (AreaSpots z_a17qB x_a17qC y_a17qD) (Colour Double) area_spots_max_radius :: Lens' (AreaSpots z_a17qB x_a17qC y_a17qD) Double area_spots_values :: Lens (AreaSpots z_a17qB x_a17qC y_a17qD) (AreaSpots z_a17AB x_a17AC y_a17AD) [(x_a17qC, y_a17qD, z_a17qB)] [(x_a17AC, y_a17AD, z_a17AB)] -- | A collection of unconnected spots, with x,y position, an independent z -- value to be represented by the area of the spot, and in addition, a -- fourth variable t to be represented by a colour from a given palette. -- (A linear transfer function from t to palette is assumed.) data AreaSpots4D z t x y AreaSpots4D :: String -> Double -> [Colour Double] -> Double -> Double -> [(x, y, z, t)] -> AreaSpots4D z t x y _area_spots_4d_title :: AreaSpots4D z t x y -> String _area_spots_4d_linethick :: AreaSpots4D z t x y -> Double _area_spots_4d_palette :: AreaSpots4D z t x y -> [Colour Double] _area_spots_4d_opacity :: AreaSpots4D z t x y -> Double -- | the largest size of spot _area_spots_4d_max_radius :: AreaSpots4D z t x y -> Double _area_spots_4d_values :: AreaSpots4D z t x y -> [(x, y, z, t)] -- | Deprecated: Use the according Data.Default instance! defaultAreaSpots4D :: AreaSpots4D z t x y area_spots_4d_title :: Lens' (AreaSpots4D z_a17qx t_a17qy x_a17qz y_a17qA) String area_spots_4d_linethick :: Lens' (AreaSpots4D z_a17qx t_a17qy x_a17qz y_a17qA) Double area_spots_4d_palette :: Lens' (AreaSpots4D z_a17qx t_a17qy x_a17qz y_a17qA) [Colour Double] area_spots_4d_max_radius :: Lens' (AreaSpots4D z_a17qx t_a17qy x_a17qz y_a17qA) Double area_spots_4d_values :: Lens (AreaSpots4D z_a17qx t_a17qy x_a17qz y_a17qA) (AreaSpots4D z_a17Ce t_a17Cf x_a17Cg y_a17Ch) [(x_a17qz, y_a17qA, z_a17qx, t_a17qy)] [(x_a17Cg, y_a17Ch, z_a17Ce, t_a17Cf)] instance (PlotValue z, PlotValue t, Show t) => ToPlot (AreaSpots4D z t) instance Default (AreaSpots4D z t x y) instance PlotValue z => ToPlot (AreaSpots z) instance Default (AreaSpots z x y) -- | A basic pie chart. -- -- Pie charts are handled different to other plots, in that they have -- their own layout, and can't be composed with other plots. A pie chart -- is rendered with code in the following form: -- --
--   values :: [PieItem]
--   values = [...]
--   layout :: PieLayout
--   layout = pie_plot ^: pie_data ^= values
--          $ defaultPieLayout
--   renderable = toRenderable layout
--   
module Graphics.Rendering.Chart.Plot.Pie data PieLayout PieLayout :: String -> FontStyle -> PieChart -> FillStyle -> Double -> PieLayout _pie_title :: PieLayout -> String _pie_title_style :: PieLayout -> FontStyle _pie_plot :: PieLayout -> PieChart _pie_background :: PieLayout -> FillStyle _pie_margin :: PieLayout -> Double data PieChart PieChart :: [PieItem] -> [AlphaColour Double] -> FontStyle -> LineStyle -> Double -> PieChart _pie_data :: PieChart -> [PieItem] _pie_colors :: PieChart -> [AlphaColour Double] _pie_label_style :: PieChart -> FontStyle _pie_label_line_style :: PieChart -> LineStyle _pie_start_angle :: PieChart -> Double data PieItem PieItem :: String -> Double -> Double -> PieItem _pitem_label :: PieItem -> String _pitem_offset :: PieItem -> Double _pitem_value :: PieItem -> Double -- | Deprecated: Use the according Data.Default instance! defaultPieLayout :: PieLayout -- | Deprecated: Use the according Data.Default instance! defaultPieChart :: PieChart -- | Deprecated: Use the according Data.Default instance! defaultPieItem :: PieItem pieToRenderable :: PieLayout -> Renderable (PickFn a) pieChartToRenderable :: PieChart -> Renderable (PickFn a) pie_title :: Lens' PieLayout String pie_title_style :: Lens' PieLayout FontStyle pie_plot :: Lens' PieLayout PieChart pie_background :: Lens' PieLayout FillStyle pie_margin :: Lens' PieLayout Double pie_data :: Lens' PieChart [PieItem] pie_colors :: Lens' PieChart [AlphaColour Double] pie_label_style :: Lens' PieChart FontStyle pie_label_line_style :: Lens' PieChart LineStyle pie_start_angle :: Lens' PieChart Double pitem_label :: Lens' PieItem String pitem_offset :: Lens' PieItem Double pitem_value :: Lens' PieItem Double instance ToRenderable PieChart instance ToRenderable PieLayout instance Default PieLayout instance Default PieItem instance Default PieChart -- | Code to calculate and render various types of plots. module Graphics.Rendering.Chart.Plot -- | 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 -- Lens) 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 :: Control.Lens.Lens' 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 :: FillStyle -> Maybe FillStyle -> String -> FontStyle -> 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 -> FillStyle _layout1_plot_background :: Layout1 x y -> Maybe FillStyle _layout1_title :: Layout1 x y -> String _layout1_title_style :: Layout1 x y -> FontStyle _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 :: FontStyle -> String -> AxisStyle -> ([x] -> Bool) -> AxisFn x -> (AxisData x -> AxisData x) -> Bool -> LayoutAxis x _laxis_title_style :: LayoutAxis x -> FontStyle _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 data Layout1Pick x y L1P_Legend :: String -> Layout1Pick x y L1P_Title :: String -> Layout1Pick x y L1P_BottomAxisTitle :: String -> Layout1Pick x y L1P_TopAxisTitle :: String -> Layout1Pick x y L1P_LeftAxisTitle :: String -> Layout1Pick x y L1P_RightAxisTitle :: String -> Layout1Pick x y L1P_PlotArea :: x -> y -> y -> Layout1Pick x y L1P_BottomAxis :: x -> Layout1Pick x y L1P_TopAxis :: x -> Layout1Pick x y L1P_LeftAxis :: y -> Layout1Pick x y L1P_RightAxis :: y -> Layout1Pick x y -- | A container for a set of vertically stacked layouts data StackedLayouts x StackedLayouts :: [StackedLayout x] -> Bool -> Bool -> StackedLayouts x _slayouts_layouts :: StackedLayouts x -> [StackedLayout x] _slayouts_compress_xlabels :: StackedLayouts x -> Bool _slayouts_compress_legend :: StackedLayouts x -> Bool -- | A layout with its y type hidden, so that it can be stacked with other -- layouts (with differing y types) data StackedLayout x StackedLayout :: (Layout1 x y) -> StackedLayout x -- | A MAxisFn is a function that generates an (optional) axis -- given the points plotted against that axis. type MAxisFn t = [t] -> Maybe (AxisData t) -- | Deprecated: Use the according Data.Default instance! defaultLayout1 :: (PlotValue x, PlotValue y) => Layout1 x y layout1ToRenderable :: (Ord x, Ord y) => Layout1 x y -> Renderable (Layout1Pick 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 -- | Deprecated: Use the according Data.Default instance! defaultLayoutAxis :: PlotValue t => LayoutAxis t laxis_title_style :: Lens' (LayoutAxis x_a1d7P) FontStyle laxis_title :: Lens' (LayoutAxis x_a1d7P) String laxis_style :: Lens' (LayoutAxis x_a1d7P) AxisStyle laxis_visible :: Lens' (LayoutAxis x_a1d7P) ([x_a1d7P] -> Bool) laxis_generate :: Lens' (LayoutAxis x_a1d7P) (AxisFn x_a1d7P) laxis_override :: Lens' (LayoutAxis x_a1d7P) (AxisData x_a1d7P -> AxisData x_a1d7P) laxis_reverse :: Lens' (LayoutAxis x_a1d7P) Bool layout1_background :: Lens' (Layout1 x_a1d70 y_a1d71) FillStyle layout1_plot_background :: Lens' (Layout1 x_a1d70 y_a1d71) (Maybe FillStyle) layout1_title :: Lens' (Layout1 x_a1d70 y_a1d71) String layout1_title_style :: Lens' (Layout1 x_a1d70 y_a1d71) FontStyle layout1_left_axis :: Lens' (Layout1 x_a1d70 y_a1d71) (LayoutAxis y_a1d71) layout1_right_axis :: Lens' (Layout1 x_a1d70 y_a1d71) (LayoutAxis y_a1d71) layout1_top_axis :: Lens' (Layout1 x_a1d70 y_a1d71) (LayoutAxis x_a1d70) layout1_bottom_axis :: Lens' (Layout1 x_a1d70 y_a1d71) (LayoutAxis x_a1d70) layout1_yaxes_control :: Lens' (Layout1 x_a1d70 y_a1d71) (([y_a1d71], [y_a1d71]) -> ([y_a1d71], [y_a1d71])) layout1_margin :: Lens' (Layout1 x_a1d70 y_a1d71) Double layout1_plots :: Lens' (Layout1 x_a1d70 y_a1d71) [Either (Plot x_a1d70 y_a1d71) (Plot x_a1d70 y_a1d71)] layout1_legend :: Lens' (Layout1 x_a1d70 y_a1d71) (Maybe LegendStyle) layout1_grid_last :: Lens' (Layout1 x_a1d70 y_a1d71) Bool -- | Deprecated: Use the according Data.Default instance! defaultStackedLayouts :: StackedLayouts x slayouts_layouts :: Lens (StackedLayouts x_a1d6V) (StackedLayouts x_a1dwB) [StackedLayout x_a1d6V] [StackedLayout x_a1dwB] slayouts_compress_xlabels :: Lens' (StackedLayouts x_a1d6V) Bool slayouts_compress_legend :: Lens' (StackedLayouts x_a1d6V) Bool -- | Render several layouts with the same x-axis type and range, vertically -- stacked so that their origins and x-values are aligned. -- -- The legends from all the charts may be optionally combined, and shown -- once on the bottom chart. The x labels may be optionally removed so -- that they are only shown once. renderStackedLayouts :: Ord x => StackedLayouts x -> Renderable () instance (Show x, Show y) => Show (Layout1Pick x y) instance PlotValue t => Default (LayoutAxis t) instance (PlotValue x, PlotValue y) => Default (Layout1 x y) instance Default (StackedLayouts x) instance (Ord x, Ord y) => ToRenderable (Layout1 x y) -- | Created : 2008-02-26 Modified : 2011-02-11 Version : 0.2 -- -- Sparklines implementation in Haskell. Sparklines are mini graphs -- inspired by Edward Tufte. -- -- The original implementation (by Hitesh Jasani) used the gd package as -- a backend renderer, and is still available at -- http:hackage.haskell.orgpackagehsparklines The present -- version uses Cairo as its renderer, and integrates with the Chart -- package, in the sense that Sparklines are just another kind of -- (ToRenderable a => a), so can be composed into grids etc. -- --
--   dp :: [Double]
--   dp = [24,21,32.3,24,15,34,43,55,57,72,74,75,73,72,55,44]
--   
--   sparkLineToPNG "bar_spark.png" (SparkLine barSpark dp)
--   
module Graphics.Rendering.Chart.SparkLine -- | A sparkline is a single sequence of data values, treated as y-values. -- The x-values are anonymous and implicit in the sequence. data SparkLine SparkLine :: SparkOptions -> [Double] -> SparkLine sl_options :: SparkLine -> SparkOptions sl_data :: SparkLine -> [Double] -- | Options to render the sparklines in different ways. data SparkOptions SparkOptions :: Bool -> Int -> Int -> (Double, Double) -> Colour Double -> Colour Double -> Colour Double -> Colour Double -> Bool -> Bool -> Bool -> SparkOptions -- | smooth or bars so_smooth :: SparkOptions -> Bool -- | step size so_step :: SparkOptions -> Int -- | graph height (pixels) so_height :: SparkOptions -> Int -- | data point limits so_limits :: SparkOptions -> (Double, Double) -- | background color so_bgColor :: SparkOptions -> Colour Double -- | color of minimum datapoint so_minColor :: SparkOptions -> Colour Double -- | color of maximum datapoint so_maxColor :: SparkOptions -> Colour Double -- | color of last datapoint so_lastColor :: SparkOptions -> Colour Double -- | display minimum marker so_minMarker :: SparkOptions -> Bool -- | display maximum marker so_maxMarker :: SparkOptions -> Bool -- | display last marker so_lastMarker :: SparkOptions -> Bool -- | Default options for a smooth sparkline. smoothSpark :: SparkOptions -- | Default options for a barchart sparkline. barSpark :: SparkOptions sparkSize :: SparkLine -> (Int, Int) -- | Render a SparkLine to a drawing surface using cairo. renderSparkLine :: SparkLine -> ChartBackend (PickFn ()) sparkLineToRenderable :: SparkLine -> Renderable () -- | Compute the width of a SparkLine, for rendering purposes. sparkWidth :: SparkLine -> Int instance Show SparkOptions instance ToRenderable SparkLine -- | 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 renderableToWindow. -- -- Currently, there are two kinds of Renderable for displaying -- charts: -- -- -- -- Multiple Renderables can be composed using the -- Graphics.Rendering.Chart.Grid module. -- -- Many of the record structure involved in the API have a large number -- of fields. For each record type X, there is generally a default value -- called defaultX with sensibly initialised fields. For example, -- Layout1 has defaultLayout1, etc. -- -- For a simpler though less flexible API, see -- Graphics.Rendering.Chart.Simple. module Graphics.Rendering.Chart module Graphics.Rendering.Chart.Simple.Internal styleColor :: Int -> AlphaColour Double styleSymbol :: Int -> PlotKind iplot :: [InternalPlot Double Double] -> Layout1 Double Double name :: [PlotKind] -> String str2k :: String -> [PlotKind] str2khelper :: String -> PlotKind -> [PlotKind] -- | 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 data InternalPlot x y IPY :: [y] -> [PlotKind] -> InternalPlot x y IPX :: [x] -> [PlotKind] -> InternalPlot x y newtype Layout1DDD Layout1DDD :: Layout1 Double Double -> Layout1DDD plotLayout :: Layout1DDD -> Layout1 Double Double layout1DddToRenderable :: Layout1DDD -> Renderable (Layout1Pick Double Double) uplot :: [UPlot] -> Layout1DDD -- | 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 class PlotType t pl :: PlotType t => [UPlot] -> t -- | Save a plot as a PDF file. plotPDF :: PlotPDFType a => String -> a class PlotPDFType t pld :: PlotPDFType t => FilePath -> [UPlot] -> t -- | Save a plot as a postscript file. plotPS :: PlotPSType a => String -> a class PlotPSType t pls :: PlotPSType t => FilePath -> [UPlot] -> t -- | Save a plot as a png file. plotPNG :: PlotPNGType a => String -> a class PlotPNGType t plp :: PlotPNGType t => FilePath -> [UPlot] -> t data UPlot UString :: String -> UPlot UDoubles :: [Double] -> UPlot UFunction :: (Double -> Double) -> UPlot UKind :: [PlotKind] -> UPlot X :: [Double] -> UPlot xcoords :: [Double] -> UPlot class PlotArg a toUPlot :: PlotArg a => a -> [UPlot] class IsPlot c toUPlot' :: IsPlot c => [c] -> [UPlot] 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 (PlotArg a, PlotPNGType r) => PlotPNGType (a -> r) instance (PlotArg a, PlotPSType r) => PlotPSType (a -> r) instance (PlotArg a, PlotPDFType r) => PlotPDFType (a -> r) instance PlotType Layout1DDD instance (PlotArg a, PlotType r) => PlotType (a -> r) instance ToRenderable Layout1DDD -- | An even simpler framework for creating 2D charts in Haskell. -- -- The basic idea is to make it as easy to plot as octave, which means -- that you provide no more information than you wish to provide. We -- provide four plotting functions, which differ only in their output. -- One produces a Layout1 that you can customize using other -- Graphics.Rendering.Chart functions. The other three produce their -- output directly. All three accept the same input and produce the same -- plots. -- -- The plot functions accept a variable number of arguments. You must -- provide a [Double] which defines the points on the x axis, which must -- precede any of the y values. The y values may either be -- [Double] or functions. After any given y value, you can give either -- Strings or PlotKinds describing how you'd like that y printed. -- -- Examples: -- --
--   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 -- | 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 layout1DddToRenderable :: Layout1DDD -> Renderable (Layout1Pick Double Double) class PlotPDFType t pld :: PlotPDFType t => FilePath -> [UPlot] -> t class PlotPSType t pls :: PlotPSType t => FilePath -> [UPlot] -> t class PlotPNGType t plp :: PlotPNGType t => FilePath -> [UPlot] -> t uplot :: [UPlot] -> Layout1DDD