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 FlexibleInstances #-}
module IHaskell.Display.Plot where
......@@ -11,8 +10,9 @@ import Graphics.Rendering.Plot
import IHaskell.Display
instance IHaskellDisplay (Figure ()) where
display figure = do
instance IHaskellDisplay (Figure a) where
display fig = do
let figure = fig >> return ()
pngDisp <- figureData figure PNG
svgDisp <- figureData figure SVG
return $ Display [pngDisp, svgDisp]
......@@ -36,9 +36,11 @@ figureData figure format = do
case format of
PNG -> png w h $ base64 imgData
SVG -> svg $ Char.unpack imgData
_ -> error "Unsupported format for display"
return value
where
extension SVG = "svg"
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