Chart-diagrams 1.2.4 → 1.3
raw patch · 2 files changed
+16/−71 lines, 2 filesdep ~ChartPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Chart
API changes (from Hackage documentation)
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToEPSFile :: Renderable a -> Double -> Double -> FilePath -> IO (PickFn a)
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToEPSFile' :: Renderable a -> DEnv -> FilePath -> IO (PickFn a)
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToEmbeddedFontSVGFile :: Renderable a -> Double -> Double -> FilePath -> IO (PickFn a)
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToEmbeddedFontSVGFile' :: Renderable a -> DEnv -> FilePath -> IO (PickFn a)
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToSVGFile :: Renderable a -> Double -> Double -> FilePath -> IO (PickFn a)
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToSVGFile' :: Renderable a -> DEnv -> FilePath -> IO (PickFn a)
+ Graphics.Rendering.Chart.Backend.Diagrams: instance Default FileOptions
+ Graphics.Rendering.Chart.Backend.Diagrams: toFile :: (Default r, ToRenderable r) => FileOptions -> FilePath -> EC r () -> IO ()
- Graphics.Rendering.Chart.Backend.Diagrams: renderableToFile :: FileOptions -> Renderable a -> FilePath -> IO (PickFn a)
+ Graphics.Rendering.Chart.Backend.Diagrams: renderableToFile :: FileOptions -> FilePath -> Renderable a -> IO (PickFn a)
Files
Chart-diagrams.cabal view
@@ -1,5 +1,5 @@ Name: Chart-diagrams-Version: 1.2.4+Version: 1.3 License: BSD3 License-file: LICENSE Copyright: Jan Bracker, 2006-2010@@ -40,7 +40,7 @@ , containers >= 0.4 && < 0.6 , data-default-class < 0.1 , lens >= 3.9 && < 4.4- , Chart >= 1.2 && < 1.3+ , Chart >= 1.3 && < 1.4 , text other-modules: Paths_Chart_diagrams Exposed-modules:
Graphics/Rendering/Chart/Backend/Diagrams.hs view
@@ -17,28 +17,23 @@ , fo_format , fo_customFonts , renderableToFile+ , toFile , cBackendToFile -- * EPS Utility Functions , cBackendToEPSFile- , renderableToEPSFile -- deprecated- , renderableToEPSFile' -- deprecated -- * SVG Utility Functions , cBackendToSVG , cBackendToEmbeddedFontSVG , renderableToSVG , renderableToSVG'- , renderableToSVGFile -- deprecated- , renderableToSVGFile' -- deprecated , renderableToSVGString , renderableToSVGString' -- * SVG Embedded Font Utility Functions , renderableToEmbeddedFontSVG , renderableToEmbeddedFontSVG'- , renderableToEmbeddedFontSVGFile -- deprecated- , renderableToEmbeddedFontSVGFile' -- deprecated ) where import Data.Default.Class@@ -85,6 +80,7 @@ import Graphics.Rendering.Chart.Geometry as G import Graphics.Rendering.Chart.Drawing import Graphics.Rendering.Chart.Renderable+import Graphics.Rendering.Chart.State(EC, execEC) import Paths_Chart_diagrams ( getDataFileName ) @@ -107,13 +103,23 @@ _fo_customFonts :: M.Map (String, FontSlant, FontWeight) FilePath } +instance Default FileOptions where+ def = FileOptions (800,600) SVG M.empty++ -- | Generate an image file for the given renderable, at the specified path. Size, format, -- and text rendering mode are all set through the `FileOptions` parameter.-renderableToFile :: FileOptions -> Renderable a -> FilePath -> IO (PickFn a)-renderableToFile fo r path = cBackendToFile fo cb path+renderableToFile :: FileOptions -> FilePath -> Renderable a -> IO (PickFn a)+renderableToFile fo path r = cBackendToFile fo cb path where cb = render r (_fo_size fo) +-- | Generate an image file from from the state content of an EC+-- computation. The state may have any type that is an instance of+-- `ToRenderable`+toFile :: (Default r,ToRenderable r) => FileOptions -> FilePath -> EC r () -> IO ()+toFile fo path ec = void $ renderableToFile fo path (toRenderable (execEC ec))+ -- | Generate an image file for the given drawing instructions, at the specified path. Size and -- format are set through the `FileOptions` parameter. cBackendToFile :: FileOptions -> ChartBackend a -> FilePath -> IO a@@ -137,23 +143,6 @@ -- SVG Utility Functions -- ----------------------------------------------------------------------- --- | Output the given renderable to a SVG file of the specifed size--- (in points), to the specified file using the default environment.-{-# DEPRECATED renderableToSVGFile "use renderToFile" #-}-renderableToSVGFile :: Renderable a -> Double -> Double -> FilePath -> IO (PickFn a)-renderableToSVGFile r w h file = do- (svg, x) <- renderableToSVGString r w h- BS.writeFile file svg- return x---- | Output the given renderable to a SVG file using the given environment.-{-# DEPRECATED renderableToSVGFile' "use renderToFile" #-}-renderableToSVGFile' :: Renderable a -> DEnv -> FilePath -> IO (PickFn a)-renderableToSVGFile' r env file = do- let (svg, x) = renderableToSVGString' r env- BS.writeFile file svg- return x- -- | Output the given renderable to a string containing a SVG of the specifed size -- (in points) using the default environment. renderableToSVGString :: Renderable a -> Double -> Double -> IO (BS.ByteString, PickFn a)@@ -187,25 +176,6 @@ -- SVG Embedded Font Utility Functions -- ----------------------------------------------------------------------- --- | Output the given renderable to a SVG file of the specifed size--- (in points), to the specified file using the default environment.--- Font are embedded to save space.-{-# DEPRECATED renderableToEmbeddedFontSVGFile "use renderToFile" #-}-renderableToEmbeddedFontSVGFile :: Renderable a -> Double -> Double -> FilePath -> IO (PickFn a)-renderableToEmbeddedFontSVGFile r w h file = do- (svg, x) <- renderableToEmbeddedFontSVG r w h- BS.writeFile file $ renderSvg svg- return x---- | Output the given renderable to a SVG file using the given environment.--- Font are embedded to save space.-{-# DEPRECATED renderableToEmbeddedFontSVGFile' "use renderToFile" #-}-renderableToEmbeddedFontSVGFile' :: Renderable a -> DEnv -> FilePath -> IO (PickFn a)-renderableToEmbeddedFontSVGFile' r env file = do- let (svg, x) = renderableToEmbeddedFontSVG' r env- BS.writeFile file $ renderSvg svg- return x- -- | Output the given renderable as a SVG of the specifed size -- (in points) using the default environment. -- Font are embedded to save space.@@ -251,31 +221,6 @@ -- M.Map (String, FontSlant, FontWeight) (S.Set String) -- makeSvgFont :: (FontData, OutlineMap) -> Set.Set String -> S.Svg svg = D.renderDia DSVG.SVG (DSVG.SVGOptions (D2.Dims w h) fontDefs) d---- -------------------------------------------------------------------------- EPS Utility Functions--- --------------------------------------------------------------------------- | Output the given renderable to a EPS file using the default environment.-{-# DEPRECATED renderableToEPSFile "use renderToFile" #-}-renderableToEPSFile :: Renderable a -> Double -> Double -> FilePath -> IO (PickFn a)-renderableToEPSFile r w h file = do- env <- defaultEnv vectorAlignmentFns w h- renderableToEPSFile' r env file---- | Output the given renderable to a EPS file using the given environment.-{-# DEPRECATED renderableToEPSFile' "use renderToFile" #-}-renderableToEPSFile' :: Renderable a -> DEnv -> FilePath -> IO (PickFn a)-renderableToEPSFile' r env file = do- let (w, h) = envOutputSize env- let (d, x) = runBackendR env r- let psOpts = DEPS.PostscriptOptions - file - (D2.Dims w h) - DEPS.EPS- D.renderDia DEPS.Postscript psOpts d- return x- -- ----------------------------------------------------------------------- -- Backend