Commit 6f194eb9 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Merge pull request #460 from sumitsahrawat/plot-patch

Generalize ihaskell-plot to work for all Figure types
parents 5ac6132f 2c96b37d
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleInstances #-}
module IHaskell.Display.Plot where module IHaskell.Display.Plot where
...@@ -11,8 +10,9 @@ import Graphics.Rendering.Plot ...@@ -11,8 +10,9 @@ import Graphics.Rendering.Plot
import IHaskell.Display import IHaskell.Display
instance IHaskellDisplay (Figure ()) where instance IHaskellDisplay (Figure a) where
display figure = do display fig = do
let figure = fig >> return ()
pngDisp <- figureData figure PNG pngDisp <- figureData figure PNG
svgDisp <- figureData figure SVG svgDisp <- figureData figure SVG
return $ Display [pngDisp, svgDisp] return $ Display [pngDisp, svgDisp]
...@@ -36,9 +36,11 @@ figureData figure format = do ...@@ -36,9 +36,11 @@ figureData figure format = do
case format of case format of
PNG -> png w h $ base64 imgData PNG -> png w h $ base64 imgData
SVG -> svg $ Char.unpack imgData SVG -> svg $ Char.unpack imgData
_ -> error "Unsupported format for display"
return value return value
where where
extension SVG = "svg" extension SVG = "svg"
extension PNG = "png" extension PNG = "png"
extension _ = ""
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment