packages feed

ihaskell-charts (empty) → 0.1.0.0

raw patch · 4 files changed

+142/−0 lines, 4 filesdep +Chartdep +Chart-cairodep +basesetup-changed

Dependencies added: Chart, Chart-cairo, base, bytestring, classy-prelude, data-default-class, directory, ihaskell

Files

+ IHaskell/Display/Charts.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE NoImplicitPrelude #-}+module IHaskell.Display.Charts () where++import ClassyPrelude++import System.Directory+import Data.Default.Class+import Graphics.Rendering.Chart.Renderable+import Graphics.Rendering.Chart.Backend.Cairo+import qualified Data.ByteString.Char8 as Char+import System.IO.Unsafe++import IHaskell.Display++width :: Width+width = 450++height :: Height+height = 300++instance IHaskellDisplay (Renderable a) where+  display renderable = do+    pngDisp <- chartData renderable PNG++    -- We can add `svg svgDisplay` to the output of `display`,+    -- but SVGs are not resizable in the IPython notebook.+    svgDisp <- chartData renderable SVG++    return $ Display [pngDisp, svgDisp]++chartData :: Renderable a -> FileFormat -> IO DisplayData+chartData renderable format = do+  -- Switch to a temporary directory so that any files we create aren't+  -- visible. On Unix, this is usually /tmp.+  try (getTemporaryDirectory >>= setCurrentDirectory) :: IO (Either SomeException ())++  -- Write the PNG image.+  let filename = ".ihaskell-chart.png"+      opts = def{_fo_format = format, _fo_size = (width, height)}+  renderableToFile opts renderable filename++  -- Convert to base64.+  imgData <- readFile $ fpFromString filename+  return $ case format of+    PNG -> png width height $ base64 imgData+    SVG -> svg $ Char.unpack imgData
+ LICENSE view
@@ -0,0 +1,20 @@+The MIT License (MIT)++Copyright (c) 2013 Andrew Gibiansky++Permission is hereby granted, free of charge, to any person obtaining a copy of+this software and associated documentation files (the "Software"), to deal in+the Software without restriction, including without limitation the rights to+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of+the Software, and to permit persons to whom the Software is furnished to do so,+subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ ihaskell-charts.cabal view
@@ -0,0 +1,74 @@+-- The name of the package.+name:                ihaskell-charts++-- The package version.  See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary:      +-+------- breaking API changes+--                   | | +----- non-breaking API additions+--                   | | | +--- code changes with no API change+version:             0.1.0.0++-- A short (one-line) description of the package.+synopsis:            IHaskell display instances for charts types++-- A longer description of the package.+-- description:         ++-- URL for the project homepage or repository.+homepage:            http://www.github.com/gibiansky/ihaskell++-- The license under which the package is released.+license:             MIT++-- The file containing the license text.+license-file:        LICENSE++-- The package author(s).+author:              Andrew Gibiansky++-- An email address to which users can send suggestions, bug reports, and +-- patches.+maintainer:          andrew.gibiansky@gmail.com++-- A copyright notice.+-- copyright:           ++category:            Development++build-type:          Simple++-- Extra files to be distributed with the package, such as examples or a +-- README.+-- extra-source-files:  ++-- Constraint on the version of Cabal needed to build this package.+cabal-version:       >=1.16+++library+  -- Modules exported by the library.+  exposed-modules:     IHaskell.Display.Charts+  +  -- Modules included in this library but not exported.+  -- other-modules:       +  +  -- Language extensions.+  default-extensions: DoAndIfThenElse+              OverloadedStrings+             +  -- Other library packages from which modules are imported.+  build-depends:       base ==4.6.*,+                       classy-prelude >=0.6,+                       bytestring,+                       data-default-class,+                       directory,+                       Chart,+                       Chart-cairo,+                       ihaskell >= 0.3+  +  -- Directories containing source files.+  -- hs-source-dirs:      +  +  -- Base language which the package is written in.+  default-language:    Haskell2010