Permalink
Browse files

Add viewBox entry to exported svg files to allow inkscape to size the…

…m correctly (issue 83)
  • Loading branch information...
1 parent 2e1dbfc commit e8d9bddcf6fab056dd5d87dd36f081748667efcb @shkoo shkoo committed Dec 19, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 Graphics/Implicit/Export/PolylineFormats.hs
View
3 Graphics/Implicit/Export/PolylineFormats.hs
@@ -15,7 +15,7 @@ import Text.Blaze.Svg11 ((!),docTypeSvg,g,polyline,toValue)
import Text.Blaze.Internal (stringValue)
import qualified Text.Blaze.Svg11.Attributes as A
-import Data.List (foldl')
+import Data.List (foldl',intersperse)
import qualified Data.List as List
svg :: [Polyline] -> Text
@@ -27,6 +27,7 @@ svg plines = renderSvg . svg11 . svg' $ plines
svg11 content = docTypeSvg ! A.version "1.1"
! A.width (stringValue $ show (xmax-xmin) ++ "mm")
! A.height (stringValue $ show (ymax-ymin) ++ "mm")
+ ! A.viewbox (stringValue $ concat . intersperse " " . map show $ [xmin, xmax, ymin, ymax])
$ content
-- The reason this isn't totally straightforwards is that svg has different coordinate system
-- and we need to compute the requisite translation.

0 comments on commit e8d9bdd

Please sign in to comment.