Chart 1.6 → 1.7
raw patch · 22 files changed
+90/−90 lines, 22 files
Files
- Chart.cabal +1/−1
- Graphics/Rendering/Chart/Axis/Types.hs +4/−4
- Graphics/Rendering/Chart/Backend.hs +3/−3
- Graphics/Rendering/Chart/Backend/Impl.hs +13/−13
- Graphics/Rendering/Chart/Drawing.hs +21/−21
- Graphics/Rendering/Chart/Grid.hs +3/−3
- Graphics/Rendering/Chart/Layout.hs +5/−5
- Graphics/Rendering/Chart/Legend.hs +3/−3
- Graphics/Rendering/Chart/Plot/Annotation.hs +1/−1
- Graphics/Rendering/Chart/Plot/AreaSpots.hs +4/−4
- Graphics/Rendering/Chart/Plot/Bars.hs +2/−2
- Graphics/Rendering/Chart/Plot/Candle.hs +3/−3
- Graphics/Rendering/Chart/Plot/ErrBars.hs +3/−3
- Graphics/Rendering/Chart/Plot/FillBetween.hs +3/−3
- Graphics/Rendering/Chart/Plot/Histogram.hs +2/−2
- Graphics/Rendering/Chart/Plot/Lines.hs +2/−2
- Graphics/Rendering/Chart/Plot/Pie.hs +6/−6
- Graphics/Rendering/Chart/Plot/Points.hs +2/−2
- Graphics/Rendering/Chart/Plot/Types.hs +2/−2
- Graphics/Rendering/Chart/Plot/Vectors.hs +2/−2
- Graphics/Rendering/Chart/Renderable.hs +4/−4
- Graphics/Rendering/Chart/SparkLine.hs +1/−1
Chart.cabal view
@@ -1,5 +1,5 @@ Name: Chart-Version: 1.6+Version: 1.7 License: BSD3 License-file: LICENSE Copyright: Tim Docker, 2006-2014
Graphics/Rendering/Chart/Axis/Types.hs view
@@ -177,7 +177,7 @@ axisLabelsOverride :: [(x,String)] -> AxisData x -> AxisData x axisLabelsOverride o ad = ad{ _axis_labels = [o] } -minsizeAxis :: AxisT x -> ChartBackend RectSize+minsizeAxis :: AxisT x -> BackendProgram RectSize minsizeAxis (AxisT at as _ ad) = do let labelVis = _axis_show_labels $ _axis_visibility ad tickVis = _axis_show_ticks $ _axis_visibility ad@@ -211,7 +211,7 @@ -- | Calculate the amount by which the labels extend beyond -- the ends of the axis.-axisOverhang :: (Ord x) => AxisT x -> ChartBackend (Double,Double)+axisOverhang :: (Ord x) => AxisT x -> BackendProgram (Double,Double) axisOverhang (AxisT at as _ ad) = do let labels = map snd . sort . concat . _axis_labels $ ad labelSizes <- withFontStyle (_axis_label_style as) $@@ -228,7 +228,7 @@ E_Left -> ohangv E_Right -> ohangh -renderAxis :: AxisT x -> RectSize -> ChartBackend (PickFn x)+renderAxis :: AxisT x -> RectSize -> BackendProgram (PickFn x) renderAxis at@(AxisT et as _ ad) sz = do let ls = _axis_line_style as vis = _axis_visibility ad@@ -333,7 +333,7 @@ reverseR r@(r0,r1) = if rev then (r1,r0) else r -- -renderAxisGrid :: RectSize -> AxisT z -> ChartBackend ()+renderAxisGrid :: RectSize -> AxisT z -> BackendProgram () renderAxisGrid sz@(w,h) at@(AxisT re as _ ad) = withLineStyle (_axis_grid_style as) $ mapM_ (drawGridLine re) (_axis_grid ad)
Graphics/Rendering/Chart/Backend.hs view
@@ -1,16 +1,16 @@ ----------------------------------------------------------------------------- -- |--- Module : Graphics.Rendering.Chart.Axis.Unit+-- Module : Graphics.Rendering.Chart.Backend -- Copyright : (c) Tim Docker 2014 -- License : BSD-style (see chart/COPYRIGHT) -- -- This module provides the API for drawing operations abstracted--- to arbitrary 'ChartBackend's.+-- to drive arbitrary Backend. module Graphics.Rendering.Chart.Backend ( -- * The backend Monad- ChartBackend+ BackendProgram -- * Backend Operations , fillPath
Graphics/Rendering/Chart/Backend/Impl.hs view
@@ -48,7 +48,7 @@ WithLineStyle :: LineStyle -> Program ChartBackendInstr a -> ChartBackendInstr a WithClipRegion :: Rect -> Program ChartBackendInstr a -> ChartBackendInstr a --- | A 'ChartBackend' provides the capability to render a chart somewhere.+-- | A 'BackendProgram' 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 @@ -62,13 +62,13 @@ -- -- Information about the semantics of the instructions can be -- found in the documentation of 'ChartBackendInstr'.-type ChartBackend a = Program ChartBackendInstr a+type BackendProgram a = Program ChartBackendInstr 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 ()+strokePath :: Path -> BackendProgram () strokePath p = singleton (StrokePath p) -- | Fill the given path using the current 'FillStyle'.@@ -76,24 +76,24 @@ -- This function does /not/ perform -- alignment operations on the path. -- See 'Path' for the exact semantic of paths.-fillPath :: Path -> ChartBackend ()+fillPath :: Path -> BackendProgram () fillPath p = singleton (FillPath p) -- | Calculate a 'TextSize' object with rendering information -- about the given string without actually rendering it.-textSize :: String -> ChartBackend TextSize+textSize :: String -> BackendProgram TextSize textSize text = singleton (GetTextSize text) -- | Draw a single-line textual label anchored by the baseline (vertical) -- left (horizontal) point. Uses the current 'FontStyle' for drawing.-drawText :: Point -> String -> ChartBackend ()+drawText :: Point -> String -> BackendProgram () drawText p text = singleton (DrawText p text) -- | 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+withTransform :: Matrix -> BackendProgram a -> BackendProgram a withTransform t p = singleton (WithTransform t p) -- | Use the given font style in this local@@ -105,24 +105,24 @@ -- 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+withFontStyle :: FontStyle -> BackendProgram a -> BackendProgram a withFontStyle fs p = singleton (WithFontStyle fs p) -- | Use the given fill style in this local -- environment when filling paths.-withFillStyle :: FillStyle -> ChartBackend a -> ChartBackend a+withFillStyle :: FillStyle -> BackendProgram a -> BackendProgram a withFillStyle fs p = singleton (WithFillStyle fs p) -- | Use the given line style in this local -- environment when stroking paths.-withLineStyle :: LineStyle -> ChartBackend a -> ChartBackend a+withLineStyle :: LineStyle -> BackendProgram a -> BackendProgram a withLineStyle ls p = singleton (WithLineStyle ls p) -- | 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+withClipRegion :: Rect -> BackendProgram a -> BackendProgram a withClipRegion c p = singleton (WithClipRegion c p) -- -----------------------------------------------------------------------@@ -130,10 +130,10 @@ -- ----------------------------------------------------------------------- -- | Get the point alignment function-getPointAlignFn :: ChartBackend (Point->Point)+getPointAlignFn :: BackendProgram (Point->Point) getPointAlignFn = liftM afPointAlignFn (singleton GetAlignments) -- | Get the coordinate alignment function-getCoordAlignFn :: ChartBackend (Point->Point)+getCoordAlignFn :: BackendProgram (Point->Point) getCoordAlignFn = liftM afCoordAlignFn (singleton GetAlignments)
Graphics/Rendering/Chart/Drawing.hs view
@@ -106,33 +106,33 @@ -- ----------------------------------------------------------------------- -- | Apply a local rotation. The angle is given in radians.-withRotation :: Double -> ChartBackend a -> ChartBackend a+withRotation :: Double -> BackendProgram a -> BackendProgram a withRotation angle = withTransform (rotate angle 1) -- | Apply a local translation.-withTranslation :: Point -> ChartBackend a -> ChartBackend a+withTranslation :: Point -> BackendProgram a -> BackendProgram a withTranslation p = withTransform (translate (pointToVec p) 1) -- | Apply a local scale.-withScale :: Vector -> ChartBackend a -> ChartBackend a+withScale :: Vector -> BackendProgram a -> BackendProgram a withScale v = withTransform (scale v 1) -- | Apply a local scale on the x-axis.-withScaleX :: Double -> ChartBackend a -> ChartBackend a+withScaleX :: Double -> BackendProgram a -> BackendProgram a withScaleX x = withScale (Vector x 1) -- | Apply a local scale on the y-axis.-withScaleY :: Double -> ChartBackend a -> ChartBackend a+withScaleY :: Double -> BackendProgram a -> BackendProgram a withScaleY y = withScale (Vector 1 y) -- | Changes the 'LineStyle' and 'FillStyle' to comply with -- the given 'PointStyle'.-withPointStyle :: PointStyle -> ChartBackend a -> ChartBackend a+withPointStyle :: PointStyle -> BackendProgram a -> BackendProgram a withPointStyle (PointStyle cl bcl bw _ _) m = withLineStyle (def { _line_color = bcl, _line_width = bw }) $ withFillStyle (solidFillStyle cl) m -withDefaultStyle :: ChartBackend a -> ChartBackend a+withDefaultStyle :: BackendProgram a -> BackendProgram a withDefaultStyle = withLineStyle def . withFillStyle def . withFontStyle def -- -----------------------------------------------------------------------@@ -150,7 +150,7 @@ -- | 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+alignStrokePath :: Path -> BackendProgram Path alignStrokePath p = do f <- getPointAlignFn return $ alignPath f p@@ -158,7 +158,7 @@ -- | 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+alignFillPath :: Path -> BackendProgram Path alignFillPath p = do f <- getCoordAlignFn return $ alignPath f p@@ -166,7 +166,7 @@ -- | 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]+alignStrokePoints :: [Point] -> BackendProgram [Point] alignStrokePoints p = do f <- getPointAlignFn return $ fmap f p@@ -174,21 +174,21 @@ -- | 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]+alignFillPoints :: [Point] -> BackendProgram [Point] alignFillPoints p = do f <- getCoordAlignFn return $ fmap f p -- | Align the point using the environment's alignment function for points. -- See 'getPointAlignFn'.-alignStrokePoint :: Point -> ChartBackend Point+alignStrokePoint :: Point -> BackendProgram Point alignStrokePoint p = do alignfn <- getPointAlignFn return (alignfn p) -- | Align the point using the environment's alignment function for coordinates. -- See 'getCoordAlignFn'.-alignFillPoint :: Point -> ChartBackend Point+alignFillPoint :: Point -> BackendProgram Point alignFillPoint p = do alignfn <- getCoordAlignFn return (alignfn p)@@ -201,11 +201,11 @@ stepPath [] = mempty -- | Draw lines between the specified points.-strokePointPath :: [Point] -> ChartBackend ()+strokePointPath :: [Point] -> BackendProgram () strokePointPath pts = strokePath $ stepPath pts -- | Fill the region with the given corners.-fillPointPath :: [Point] -> ChartBackend ()+fillPointPath :: [Point] -> BackendProgram () fillPointPath pts = fillPath $ stepPath pts -- -----------------------------------------------------------------------@@ -214,7 +214,7 @@ -- | Draw a line of text that is aligned at a different anchor point. -- See 'drawText'.-drawTextA :: HTextAnchor -> VTextAnchor -> Point -> String -> ChartBackend ()+drawTextA :: HTextAnchor -> VTextAnchor -> Point -> String -> BackendProgram () drawTextA hta vta = drawTextR hta vta 0 {- @@ -234,7 +234,7 @@ -- 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 ()+drawTextR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> BackendProgram () drawTextR hta vta angle p s = withTranslation p $ withRotation theta $ do@@ -247,7 +247,7 @@ -- 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 ()+drawTextsR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> BackendProgram () drawTextsR hta vta angle p s = case num of 0 -> return () 1 -> drawTextR hta vta angle p s@@ -298,7 +298,7 @@ -- | 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+textDrawRect :: HTextAnchor -> VTextAnchor -> Point -> String -> BackendProgram Rect textDrawRect hta vta (Point x y) s = do ts <- textSize s -- This does not account for the pixel width of the label; e.g.@@ -316,7 +316,7 @@ -- | Get the width and height of the string when rendered. -- See 'textSize'.-textDimension :: String -> ChartBackend RectSize+textDimension :: String -> BackendProgram RectSize textDimension s = do ts <- textSize s return (textSizeWidth ts, textSizeHeight ts)@@ -361,7 +361,7 @@ -- | Draw a single point at the given location. drawPoint :: PointStyle -- ^ Style to use when rendering the point. -> Point -- ^ Position of the point to render.- -> ChartBackend ()+ -> BackendProgram () drawPoint ps@(PointStyle cl _ _ r shape) p = withPointStyle ps $ do p'@(Point x y) <- alignStrokePoint p case shape of
Graphics/Rendering/Chart/Grid.hs view
@@ -218,9 +218,9 @@ ---------------------------------------------------------------------- type DArray = Array Int Double -getSizes :: Grid (Renderable a) -> ChartBackend (DArray, DArray, DArray, DArray)+getSizes :: Grid (Renderable a) -> BackendProgram (DArray, DArray, DArray, DArray) getSizes t = do- szs <- mapGridM minsize t :: ChartBackend (Grid RectSize)+ szs <- mapGridM minsize t :: BackendProgram (Grid RectSize) let szs' = flatten szs let widths = accumArray max 0 (0, width t - 1) (foldT (ef wf fst) [] szs')@@ -246,7 +246,7 @@ gridToRenderable :: Grid (Renderable a) -> Renderable a gridToRenderable gt = Renderable minsizef renderf where- minsizef :: ChartBackend RectSize+ minsizef :: BackendProgram RectSize minsizef = do (widths, heights, _, _) <- getSizes gt return (sum (elems widths), sum (elems heights))
Graphics/Rendering/Chart/Layout.hs view
@@ -157,7 +157,7 @@ | LayoutPick_YRightAxis y2 -- ^ The right y axis at the given plot coordinate. deriving (Show) -type LegendItem = (String,Rect -> ChartBackend ())+type LegendItem = (String,Rect -> BackendProgram ()) -- | A Layout value is a single plot area, with single x and y -- axis. The title is at the top and the legend at the bottom. It's@@ -261,7 +261,7 @@ } -- | Render the plots of a 'Layout' to a plot area of given size.- renderPlots :: Layout x y -> RectSize -> ChartBackend (PickFn (LayoutPick x y y))+ renderPlots :: Layout x y -> RectSize -> BackendProgram (PickFn (LayoutPick x y y)) renderPlots lxy sz@(w,h) = do unless (_layout_grid_last lxy) (renderGrids sz axes) withClipRegion (Rect (Point 0 0) (Point w h)) $@@ -441,7 +441,7 @@ render = renderPlots llr } - renderPlots :: LayoutLR x yl yr -> RectSize -> ChartBackend (PickFn (LayoutPick x yl yr))+ renderPlots :: LayoutLR x yl yr -> RectSize -> BackendProgram (PickFn (LayoutPick x yl yr)) renderPlots llr sz@(w,h) = do unless (_layoutlr_grid_last llr) (renderGrids sz axes) withClipRegion (Rect (Point 0 0) (Point w h)) $@@ -675,7 +675,7 @@ gapG = tval $ spacer (lge_margin lge,0) -- | Render the grids of the given axis to a plot area of given size.-renderGrids :: RectSize -> (Maybe (AxisT x), Maybe (AxisT yl), Maybe (AxisT x), Maybe (AxisT yr)) -> ChartBackend ()+renderGrids :: RectSize -> (Maybe (AxisT x), Maybe (AxisT yl), Maybe (AxisT x), Maybe (AxisT yr)) -> BackendProgram () renderGrids sz (bAxis, lAxis, tAxis, rAxis) = do maybeM () (renderAxisGrid sz) tAxis maybeM () (renderAxisGrid sz) bAxis@@ -688,7 +688,7 @@ -- | Render a single set of plot data onto a plot area of given size using -- the given x and y axis.-renderSinglePlot :: RectSize -> Maybe (AxisT x) -> Maybe (AxisT y) -> Plot x y -> ChartBackend ()+renderSinglePlot :: RectSize -> Maybe (AxisT x) -> Maybe (AxisT y) -> Plot x y -> BackendProgram () renderSinglePlot (w, h) (Just (AxisT _ _ xrev xaxis)) (Just (AxisT _ _ yrev yaxis)) p = let xr = optPairReverse xrev (0, w) yr = optPairReverse yrev (h, 0)
Graphics/Rendering/Chart/Legend.hs view
@@ -45,7 +45,7 @@ | LOCols Int -data Legend x y = Legend LegendStyle [(String, Rect -> ChartBackend ())]+data Legend x y = Legend LegendStyle [(String, Rect -> BackendProgram ())] instance ToRenderable (Legend x y) where toRenderable = setPickFn nullPickFn . legendToRenderable@@ -62,10 +62,10 @@ mkGrid n join1 join2 = join1 [ join2 (map rf ps1) | ps1 <- groups n ps ] - ps :: [(String, [Rect -> ChartBackend ()])]+ ps :: [(String, [Rect -> BackendProgram ()])] ps = join_nub lvs - rf :: (String,[Rect -> ChartBackend ()]) -> Grid (Renderable String)+ rf :: (String,[Rect -> BackendProgram ()]) -> Grid (Renderable String) rf (title,rfs) = besideN [gpic,ggap2,gtitle] where gpic = besideN $ intersperse ggap2 (map rp rfs)
Graphics/Rendering/Chart/Plot/Annotation.hs view
@@ -48,7 +48,7 @@ vs = _plot_annotation_values p -renderAnnotation :: PlotAnnotation x y -> PointMapFn x y -> ChartBackend ()+renderAnnotation :: PlotAnnotation x y -> PointMapFn x y -> BackendProgram () renderAnnotation p pMap = withFontStyle style $ mapM_ drawOne values where hta = _plot_annotation_hanchor p
Graphics/Rendering/Chart/Plot/AreaSpots.hs view
@@ -71,7 +71,7 @@ , map (^._2) (_area_spots_values p) ) } -renderAreaSpots :: (PlotValue z) => AreaSpots z x y -> PointMapFn x y -> ChartBackend ()+renderAreaSpots :: (PlotValue z) => AreaSpots z x y -> PointMapFn x y -> BackendProgram () renderAreaSpots p pmap = forM_ (scaleMax (_area_spots_max_radius p^(2::Integer)) (_area_spots_values p))@@ -93,7 +93,7 @@ scale v = n * toValue v / largest in over (mapped._3) scale points -renderSpotLegend :: AreaSpots z x y -> Rect -> ChartBackend ()+renderSpotLegend :: AreaSpots z x y -> Rect -> BackendProgram () renderSpotLegend p (Rect p1 p2) = do let radius = min (abs (p_y p1 - p_y p2)) (abs (p_x p1 - p_x p2)) centre = linearInterpolate p1 p2@@ -141,7 +141,7 @@ } renderAreaSpots4D :: (PlotValue z, PlotValue t, Show t) =>- AreaSpots4D z t x y -> PointMapFn x y -> ChartBackend ()+ AreaSpots4D z t x y -> PointMapFn x y -> BackendProgram () renderAreaSpots4D p pmap = forM_ (scaleMax (_area_spots_4d_max_radius p^(2::Integer)) (length (_area_spots_4d_palette p))@@ -173,7 +173,7 @@ in map (\ (x,y,z,t) -> (x,y, scale z, select t)) points -renderSpotLegend4D :: AreaSpots4D z t x y -> Rect -> ChartBackend ()+renderSpotLegend4D :: AreaSpots4D z t x y -> Rect -> BackendProgram () renderSpotLegend4D p (Rect p1 p2) = do let radius = min (abs (p_y p1 - p_y p2)) (abs (p_x p1 - p_x p2)) centre = linearInterpolate p1 p2
Graphics/Rendering/Chart/Plot/Bars.hs view
@@ -129,7 +129,7 @@ _plot_all_points = allBarPoints p } -renderPlotBars :: (BarsPlotValue y) => PlotBars x y -> PointMapFn x y -> ChartBackend ()+renderPlotBars :: (BarsPlotValue y) => PlotBars x y -> PointMapFn x y -> BackendProgram () renderPlotBars p pmap = case _plot_bars_style p of BarsClustered -> forM_ vals clusteredBars BarsStacked -> forM_ vals stackedBars@@ -209,7 +209,7 @@ stack :: (BarsPlotValue y) => [y] -> [y] stack = scanl1 barsAdd -renderPlotLegendBars :: (FillStyle,Maybe LineStyle) -> Rect -> ChartBackend ()+renderPlotLegendBars :: (FillStyle,Maybe LineStyle) -> Rect -> BackendProgram () renderPlotLegendBars (fstyle,_) r = withFillStyle fstyle $ fillPath (rectPath r)
Graphics/Rendering/Chart/Plot/Candle.hs view
@@ -74,7 +74,7 @@ where pts = _plot_candle_values p -renderPlotCandle :: PlotCandle x y -> PointMapFn x y -> ChartBackend ()+renderPlotCandle :: PlotCandle x y -> PointMapFn x y -> BackendProgram () renderPlotCandle p pmap = mapM_ (drawCandle p . candlemap) (_plot_candle_values p) where@@ -87,7 +87,7 @@ (Point _ hi') = pmap' (x,hi) pmap' = mapXY pmap -drawCandle :: PlotCandle x y -> Candle Double Double -> ChartBackend ()+drawCandle :: PlotCandle x y -> Candle Double Double -> BackendProgram () drawCandle ps (Candle x lo open mid close hi) = do let tl = _plot_candle_tick_length ps let wd = _plot_candle_width ps@@ -123,7 +123,7 @@ when (ct > 0) $ strokePath $ moveTo' (x-ct) mid <> lineTo' (x+ct) mid -renderPlotLegendCandle :: PlotCandle x y -> Rect -> ChartBackend ()+renderPlotLegendCandle :: PlotCandle x y -> Rect -> BackendProgram () renderPlotLegendCandle pc (Rect p1 p2) = do drawCandle pc2 (Candle (xwid*1/4) lo open mid close hi) drawCandle pc2 (Candle (xwid*2/3) lo close mid open hi)
Graphics/Rendering/Chart/Plot/ErrBars.hs view
@@ -75,7 +75,7 @@ where pts = _plot_errbars_values p -renderPlotErrBars :: PlotErrBars x y -> PointMapFn x y -> ChartBackend ()+renderPlotErrBars :: PlotErrBars x y -> PointMapFn x y -> BackendProgram () renderPlotErrBars p pmap = mapM_ (drawErrBar.epmap) (_plot_errbars_values p) where@@ -87,7 +87,7 @@ drawErrBar = drawErrBar0 p pmap' = mapXY pmap -drawErrBar0 :: PlotErrBars x y -> ErrPoint Double Double -> ChartBackend ()+drawErrBar0 :: PlotErrBars x y -> ErrPoint Double Double -> BackendProgram () drawErrBar0 ps (ErrPoint (ErrValue xl x xh) (ErrValue yl y yh)) = do let tl = _plot_errbars_tick_length ps let oh = _plot_errbars_overhang ps@@ -105,7 +105,7 @@ <> moveTo' (x-tl) yh <> lineTo' (x+tl) yh -renderPlotLegendErrBars :: PlotErrBars x y -> Rect -> ChartBackend ()+renderPlotLegendErrBars :: PlotErrBars x y -> Rect -> BackendProgram () renderPlotLegendErrBars p (Rect p1 p2) = do drawErrBar (symErrPoint (p_x p1) y dx dx) drawErrBar (symErrPoint ((p_x p1 + p_x p2)/2) y dx dx)
Graphics/Rendering/Chart/Plot/FillBetween.hs view
@@ -43,7 +43,7 @@ _plot_all_points = plotAllPointsFillBetween p } -renderPlotFillBetween :: PlotFillBetween x y -> PointMapFn x y -> ChartBackend ()+renderPlotFillBetween :: PlotFillBetween x y -> PointMapFn x y -> BackendProgram () renderPlotFillBetween p = renderPlotFillBetween' p (_plot_fillbetween_values p) @@ -51,7 +51,7 @@ PlotFillBetween x y -> [(a, (b, b))] -> ((Limit a, Limit b) -> Point)- -> ChartBackend ()+ -> BackendProgram () renderPlotFillBetween' _ [] _ = return () renderPlotFillBetween' p vs pmap = withFillStyle (_plot_fillbetween_style p) $ do@@ -62,7 +62,7 @@ (p0:p1s) = map pmap' [ (x,y1) | (x,(y1,_)) <- vs ] p2s = map pmap' [ (x,y2) | (x,(_,y2)) <- vs ] -renderPlotLegendFill :: PlotFillBetween x y -> Rect -> ChartBackend ()+renderPlotLegendFill :: PlotFillBetween x y -> Rect -> BackendProgram () renderPlotLegendFill p r = withFillStyle (_plot_fillbetween_style p) $ fillPath (rectPath r)
Graphics/Rendering/Chart/Plot/Histogram.hs view
@@ -135,7 +135,7 @@ pt x y = pmap (LValue x, LValue y) renderPlotHist :: (RealFrac x, Num y, Ord y)- => PlotHist x y -> PointMapFn x y -> ChartBackend ()+ => PlotHist x y -> PointMapFn x y -> BackendProgram () renderPlotHist p pmap | null bins = return () | otherwise = do@@ -151,7 +151,7 @@ <> lineTo (pt x1 y) ) $ tail bins -renderPlotLegendHist :: PlotHist x y -> Rect -> ChartBackend ()+renderPlotLegendHist :: PlotHist x y -> Rect -> BackendProgram () renderPlotLegendHist p (Rect p1 p2) = withLineStyle (_plot_hist_line_style p) $ let y = (p_y p1 + p_y p2) / 2
Graphics/Rendering/Chart/Plot/Lines.hs view
@@ -54,7 +54,7 @@ xs = [ x | (LValue x,_) <- concat (_plot_lines_limit_values p)] ys = [ y | (_,LValue y) <- concat (_plot_lines_limit_values p)] -renderPlotLines :: PlotLines x y -> PointMapFn x y -> ChartBackend ()+renderPlotLines :: PlotLines x y -> PointMapFn x y -> BackendProgram () renderPlotLines p pmap = withLineStyle (_plot_lines_style p) $ do mapM_ (drawLines (mapXY pmap)) (_plot_lines_values p)@@ -62,7 +62,7 @@ where drawLines mapfn pts = alignStrokePoints (map mapfn pts) >>= strokePointPath -renderPlotLegendLines :: PlotLines x y -> Rect -> ChartBackend ()+renderPlotLegendLines :: PlotLines x y -> Rect -> BackendProgram () renderPlotLegendLines p (Rect p1 p2) = withLineStyle (_plot_lines_style p) $ do let y = (p_y p1 + p_y p2) / 2
Graphics/Rendering/Chart/Plot/Pie.hs view
@@ -127,7 +127,7 @@ title = label (_pie_title_style p) HTA_Centre VTA_Top (_pie_title p) lm = _pie_margin p -extraSpace :: PieChart -> ChartBackend (Double, Double) +extraSpace :: PieChart -> BackendProgram (Double, Double) extraSpace p = do textSizes <- mapM (textDimension . _pitem_label) (_pie_data p) let maxw = foldr (max.fst) 0 textSizes @@ -136,12 +136,12 @@ let extra = label_rgap + label_rlength + maxo return (extra + maxw, extra + maxh ) -minsizePie :: PieChart -> ChartBackend (Double, Double) +minsizePie :: PieChart -> BackendProgram (Double, Double) minsizePie p = do (extraw,extrah) <- extraSpace p return (extraw * 2, extrah * 2) -renderPie :: PieChart -> (Double, Double) -> ChartBackend (PickFn a) +renderPie :: PieChart -> (Double, Double) -> BackendProgram (PickFn a) renderPie p (w,h) = do (extraw,extrah) <- extraSpace p -- let (w,h) = (p_x p2 - p_x p1, p_y p2 - p_y p1) @@ -162,7 +162,7 @@ | pitem <- _pie_data p ] paint :: Point -> Double -> Double -> (AlphaColour Double, PieItem) - -> ChartBackend Double + -> BackendProgram Double paint center radius a1 (color,pitem) = do let ax = 360.0 * _pitem_value pitem let a2 = a1 + (ax / 2) @@ -175,7 +175,7 @@ return a3 where - pieLabel :: String -> Double -> Double -> ChartBackend () + pieLabel :: String -> Double -> Double -> BackendProgram () pieLabel name angle offset = withFontStyle (_pie_label_style p) $ withLineStyle (_pie_label_line_style p) $ do @@ -193,7 +193,7 @@ let p2 = p1 `pvadd` Vector (offset' label_rgap) 0 drawTextA anchor VTA_Bottom p2 name - pieSlice :: Point -> Double -> Double -> AlphaColour Double -> ChartBackend () + pieSlice :: Point -> Double -> Double -> AlphaColour Double -> BackendProgram () pieSlice (Point x y) arc1 arc2 pColor = do let path = arc' x y radius (radian arc1) (radian arc2) <> lineTo' x y
Graphics/Rendering/Chart/Plot/Points.hs view
@@ -42,14 +42,14 @@ where pts = _plot_points_values p -renderPlotPoints :: PlotPoints x y -> PointMapFn x y -> ChartBackend ()+renderPlotPoints :: PlotPoints x y -> PointMapFn x y -> BackendProgram () renderPlotPoints p pmap = mapM_ (drawPoint ps . pmap') (_plot_points_values p) where pmap' = mapXY pmap ps = _plot_points_style p -renderPlotLegendPoints :: PlotPoints x y -> Rect -> ChartBackend ()+renderPlotLegendPoints :: PlotPoints x y -> Rect -> BackendProgram () renderPlotLegendPoints p (Rect p1 p2) = do drawPoint ps (Point (p_x p1) y) drawPoint ps (Point ((p_x p1 + p_x p2)/2) y)
Graphics/Rendering/Chart/Plot/Types.hs view
@@ -31,12 +31,12 @@ -- | Given the mapping between model space coordinates and device -- coordinates, render this plot into a chart.- _plot_render :: PointMapFn x y -> ChartBackend (),+ _plot_render :: PointMapFn x y -> BackendProgram (), -- | 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 :: [ (String, Rect -> ChartBackend ()) ],+ _plot_legend :: [ (String, Rect -> BackendProgram ()) ], -- | All of the model space coordinates to be plotted. These are -- used to autoscale the axes where necessary.
Graphics/Rendering/Chart/Plot/Vectors.hs view
@@ -75,7 +75,7 @@ pts = concatMap (\(a,b) -> [a,b]) (pvals ++ mvals) renderPlotVectors :: (PlotValue x, PlotValue y)- => PlotVectors x y -> PointMapFn x y -> ChartBackend ()+ => PlotVectors x y -> PointMapFn x y -> BackendProgram () renderPlotVectors pv pmap = do let pvals = _plot_vectors_values pv mvals = mapGrid (_plot_vectors_grid pv) (_plot_vectors_mapf pv)@@ -111,7 +111,7 @@ (drawPoint (hs theta) (Point x y)) renderPlotLegendVectors :: (PlotValue x, PlotValue y)- => PlotVectors x y -> Rect -> ChartBackend ()+ => PlotVectors x y -> Rect -> BackendProgram () renderPlotLegendVectors pv (Rect p1 p2) = do let y = (p_y p1 + p_y p2)/2 pv' = plot_vectors_grid .~ []
Graphics/Rendering/Chart/Renderable.hs view
@@ -61,13 +61,13 @@ data Renderable a = Renderable { -- | Calculate the minimum size of the renderable.- minsize :: ChartBackend RectSize,+ minsize :: BackendProgram RectSize, -- | Draw the renderable with a rectangle, which covers -- the origin to a given point. -- -- The resulting "pick" function maps a point in the image to a value.- render :: RectSize -> ChartBackend (PickFn a)+ render :: RectSize -> BackendProgram (PickFn a) } -- | A type class abtracting the conversion of a value to a Renderable.@@ -133,8 +133,8 @@ render r rsize -- | Helper function for using a renderable, when we generate it--- in the ChartBackend monad.-embedRenderable :: ChartBackend (Renderable a) -> Renderable a+-- in the BackendProgram monad.+embedRenderable :: BackendProgram (Renderable a) -> Renderable a embedRenderable ca = Renderable { minsize = do { a <- ca; minsize a }, render = \ r -> do { a <- ca; render a r }
Graphics/Rendering/Chart/SparkLine.hs view
@@ -117,7 +117,7 @@ sparkSize s = (sparkWidth s, so_height (sl_options s)) -- | Render a SparkLine to a drawing surface.-renderSparkLine :: SparkLine -> ChartBackend (PickFn ())+renderSparkLine :: SparkLine -> BackendProgram (PickFn ()) renderSparkLine SparkLine{sl_options=opt, sl_data=ds} = let w = 4 + (so_step opt) * (length ds - 1) + extrawidth extrawidth | so_smooth opt = 0