Skip to content

Commit

Permalink
diagrams: Port to diagrams-1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bgamari committed Jun 1, 2015
1 parent 54432cb commit 6ba7cd4
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 165 deletions.
13 changes: 7 additions & 6 deletions chart-diagrams/Chart-diagrams.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ library
Build-depends: base >= 3 && < 5
, old-locale
, time, mtl
, diagrams-core >= 1.2 && < 1.3
, diagrams-lib >= 1.2 && < 1.3
, diagrams-svg >= 1.1 && < 1.2
, diagrams-postscript >= 0.7 && < 1.2
, SVGFonts >= 1.4 && < 1.5
, diagrams-core >= 1.3 && < 1.4
, diagrams-lib >= 1.2 && < 1.4
, diagrams-svg >= 1.3.1 && < 1.4
, diagrams-postscript >= 0.7 && < 1.4
, SVGFonts >= 1.4 && < 1.6
, colour >= 2.2.1 && < 2.4
, blaze-svg >= 0.3.3
, blaze-markup >= 0.7 && < 0.8
, lucid-svg >= 0.4 && < 0.5
, bytestring >= 0.9 && < 1.0
, operational >= 0.2.2 && < 0.3
, containers >= 0.4 && < 0.6
Expand Down
305 changes: 164 additions & 141 deletions chart-diagrams/Graphics/Rendering/Chart/Backend/Diagrams.hs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions chart-tests/Chart-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Executable harness
lens >= 3.9 && < 4.12,
data-default-class < 0.1,
bytestring >= 0.9 && < 1.0,
blaze-svg >= 0.3.3,
lucid-svg >= 0.3.3,
random >= 1.0,
containers >= 0.4 && <0.6,
old-time >= 1.0,
Expand All @@ -38,11 +38,11 @@ Executable harness
Chart-diagrams >= 1.3 && < 1.5,
gtk >= 0.9.11,
cairo >= 0.9.11,
diagrams-cairo >= 1.2 && < 1.3,
diagrams-svg >= 1.1 && < 1.2,
diagrams-postscript >= 0.7 && < 1.2,
diagrams-lib >= 1.2 && < 1.3,
diagrams-core >= 1.2 && < 1.3
diagrams-cairo >= 1.2 && < 1.4,
diagrams-svg >= 1.1 && < 1.4,
diagrams-postscript >= 0.7 && < 1.4,
diagrams-lib >= 1.2 && < 1.4,
diagrams-core >= 1.2 && < 1.4
Main-is: Main.hs
Hs-Source-Dirs: tests
Ghc-Options: -threaded
Expand Down
4 changes: 2 additions & 2 deletions chart-tests/tests/CompareFonts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import qualified Graphics.Rendering.Chart.Backend.Diagrams as BD
import qualified Graphics.Rendering.Chart.Backend.Cairo as BC

import Diagrams.Core ( renderDia )
import Diagrams.TwoD ( SizeSpec2D(..) )
import Diagrams.Prelude ( dims, V2(..) )
import Diagrams.Backend.Cairo hiding ( renderCairo )
import Diagrams.Backend.Cairo.Internal

Expand Down Expand Up @@ -95,4 +95,4 @@ renderDiagramsCairo :: (Int, Int) -> ChartBackend () -> IO (C.Render ())
renderDiagramsCairo (w,h) m = do
env <- BD.defaultEnv bitmapAlignmentFns (fromIntegral w) (fromIntegral h)
let (d, _) = BD.runBackend env m
return $ snd $ renderDia Cairo (CairoOptions "" (Dims (fromIntegral w) (fromIntegral h)) PNG True) d
return $ snd $ renderDia Cairo (CairoOptions "" (dims $ V2 (fromIntegral w) (fromIntegral h)) PNG True) d
4 changes: 2 additions & 2 deletions chart-tests/tests/DiagramsCairo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Graphics.Rendering.Chart.Backend
import Graphics.Rendering.Chart.Backend.Diagrams

import Diagrams.Core ( renderDia )
import Diagrams.TwoD ( SizeSpec2D(..) )
import Diagrams.Prelude ( dims, V2(..) )
import Diagrams.Backend.Cairo
import Diagrams.Backend.Cairo.Internal
import Graphics.Rendering.Chart.Renderable ( render, Renderable )
Expand All @@ -26,5 +26,5 @@ main1 args = do
renderDiagram (n,(w,h),ir) = do
let env' = env { envOutputSize = (fromIntegral w, fromIntegral h) }
(d, _) = runBackendR env' (ir 1.0)
fst $ renderDia Cairo (CairoOptions (n ++ ".png") (Dims (fromIntegral w) (fromIntegral h)) PNG False) d
fst $ renderDia Cairo (CairoOptions (n ++ ".png") (dims $ V2 (fromIntegral w) (fromIntegral h)) PNG False) d
showTests (fmap (\(x,_,_) -> x) allTests) renderDiagram
3 changes: 1 addition & 2 deletions chart-tests/tests/DiagramsEPS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Graphics.Rendering.Chart.Backend
import Graphics.Rendering.Chart.Backend.Diagrams

import Diagrams.Core ( renderDia )
import Diagrams.TwoD ( SizeSpec2D(..) )
import Graphics.Rendering.Chart.Renderable ( render, Renderable )
import qualified Diagrams.Backend.Postscript as DEPS

Expand All @@ -24,7 +23,7 @@ main1 args = do
env0 <- defaultEnv bitmapAlignmentFns 0 0
showTests (fmap (\(x,_,_) -> x) allTests) (renderDiagram env0)
where
renderDiagram :: DEnv -> (String, (Int, Int), T.LineWidth -> Renderable ()) -> IO ()
renderDiagram :: DEnv Double -> (String, (Int, Int), T.LineWidth -> Renderable ()) -> IO ()
renderDiagram env0 (n,(w,h),ir) = do
let cr = render (ir 0.25) (fromIntegral w, fromIntegral h)
env = env0{ envOutputSize = (fromIntegral w, fromIntegral h) }
Expand Down
7 changes: 3 additions & 4 deletions chart-tests/tests/DiagramsSVG.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import Graphics.Rendering.Chart.Backend.Diagrams
import qualified Data.ByteString.Lazy as BS

import Diagrams.Core ( renderDia )
import Diagrams.TwoD ( SizeSpec2D(..) )
import Diagrams.Backend.SVG
import Graphics.Rendering.Chart.Renderable ( render, Renderable )
import Text.Blaze.Svg.Renderer.Utf8 ( renderSvg )
import Lucid.Svg ( renderBS )

import System.Environment ( getArgs )

Expand All @@ -27,11 +26,11 @@ main1 args = do
env0 <- defaultEnv bitmapAlignmentFns 0 0
showTests (fmap (\(x,_,_) -> x) allTests) (renderDiagram env0)
where
renderDiagram :: DEnv -> (String, (Int, Int), T.LineWidth -> Renderable ()) -> IO ()
renderDiagram :: DEnv Double -> (String, (Int, Int), T.LineWidth -> Renderable ()) -> IO ()
renderDiagram env0 (n,(w,h),ir) = do
let cr = render (ir 0.25) (fromIntegral w, fromIntegral h)
env = env0{ envOutputSize = (fromIntegral w, fromIntegral h) }
(svg, _) = cBackendToSVG cr env
path = n ++ ".svg"
putStrLn (path ++ "...")
BS.writeFile path (renderSvg svg)
BS.writeFile path (renderBS svg)
4 changes: 2 additions & 2 deletions chart-tests/tests/Drawing/DiagramsCairo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Graphics.Rendering.Chart.Backend
import Graphics.Rendering.Chart.Backend.Diagrams

import Diagrams.Core ( renderDia )
import Diagrams.TwoD ( SizeSpec2D(..) )
import Diagrams.Prelude ( dims, V2(..) )
import Diagrams.Backend.Cairo
import Diagrams.Backend.Cairo.Internal

Expand All @@ -19,4 +19,4 @@ render :: FilePath -> Int -> Int -> ChartBackend a -> IO ()
render f w h m = do
env <- defaultEnv bitmapAlignmentFns (fromIntegral w) (fromIntegral h)
let (d, _) = runBackend env m
fst $ renderDia Cairo (CairoOptions f (Dims (fromIntegral w) (fromIntegral h)) PNG False) d
fst $ renderDia Cairo (CairoOptions f (dims $ V2 (fromIntegral w) (fromIntegral h)) PNG False) d

0 comments on commit 6ba7cd4

Please sign in to comment.