ihaskell-hvega 0.1.0.0 → 0.1.0.1
raw patch · 6 files changed
+124/−80 lines, 6 filesdep ~aeson
Dependency ranges changed: aeson
Files
- CHANGELOG.md +22/−0
- IHaskell/Display/Hvega.hs +0/−75
- default.nix +10/−0
- ihaskell-hvega.cabal +9/−5
- src/IHaskell/Display/Hvega.hs +75/−0
- stack.yaml +8/−0
+ CHANGELOG.md view
@@ -0,0 +1,22 @@+For the latest version of this document, please see+[https://github.com/DougBurke/hvega/blob/master/ihaskell-hvega/CHANGELOG.md](https://github.com/DougBurke/hvega/blob/master/ihaskell-hvega/CHANGELOG.md).++## 0.1.0.1++The source code has been moved to the `src` sub-directory to match the+layout used by `hvega`.++Several incorrect links in the cabal file have been fixed (as my GitHub+user name is not actually `githubuser`).++The cabal package now includes `stack.yaml` and `default.nix` (although+the latter is *not* guaranteed to be correct), as well as a+change log.++Since `ihaskell` is now in Stackage, the LTS version has been updated+to reflect this (to LTS 11.19), and the extra dependency removed.++## 0.1.0.0++This is the initial version of `ihaskell-hvega`, and is released with+`hvega` version 0.1.0.0.
− IHaskell/Display/Hvega.hs
@@ -1,75 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}--module IHaskell.Display.Hvega where--import qualified Data.Text.Lazy as LT--import Data.Aeson.Text (encodeToLazyText)-import Data.Monoid ((<>))--import Graphics.Vega.VegaLite (VegaLite, fromVL)--import IHaskell.Display (IHaskellDisplay(..), Display(..), javascript)----- ^ Use <https://vega.github.io/vega-lite/usage/embed.html Vega-Embed>--- to include the Vega-Lite visualization in an IHaskell notebook.------ There is currently no way to pass--- <https://github.com/vega/vega-embed#options options>--- to the @vegaEmbed@ call.------ Note that local file access is __not__ guaranteed to work - e.g.--- @dataFromUrl@ where the file name refers to a local file ---- since the JavaScript @fs@ module may not be loaded.----instance IHaskellDisplay VegaLite where- display vl = - - let -- Note: need to look in the package.json files for these packages- -- to find the "full name" (the contents of the jsdelivr key),- -- since requirejs does seem to like appending .js to everything.- --- jsname n v = "'https://cdn.jsdelivr.net/npm/"- <> n- <> "@" <> v- <> "/build/"- <> n <> ".min'"-- -- Should the config be set on require or requirejs?- --- -- These versions are known to work; later versions- -- do not work but I have not tried to work out the- -- latest version that does work.- --- config = "requirejs({paths:{vg:" <> jsname "vega" "3.2.1"- <> ",vl:" <> jsname "vega-lite" "2.3.0"- <> ",vge:" <> jsname "vega-embed" "3.5.2"- <> "},shim:{vge:{deps:['vg.global','vl.global']}"- <> ",vl:{deps:['vg']}"- <> "}});"- <> "define('vg.global',['vg'],function(g){window.vega = g;});"- <> "define('vl.global',['vl'],function(g){window.vl = g;});"-- -- rely on the element variable being set up; it appears to be an array- -- so use the first element to add the div to.- makeDiv = "var ndiv = document.createElement('div');"- <> "ndiv.innerHTML = "- <> "'Awesome Vega-Lite visualization to appear here';"- <> "element[0].appendChild(ndiv);"- - js = LT.unpack (encodeToLazyText (fromVL vl))-- -- Use the div element we have just created for the plot.- -- More options could be passed to vegaEmbed.- --- plot = "require(['vge'],function(vegaEmbed){"- <> "vegaEmbed(ndiv," <> js <> ").then("- <> "function (result) { console.log(result); }).catch("- <> "function (error) { ndiv.innerHTML = "- <> "'There was an error: ' + error; });"- <> "});"- - ds = [javascript (config <> makeDiv <> plot)]- - in pure (Display ds)
+ default.nix view
@@ -0,0 +1,10 @@+{ mkDerivation, aeson, base, hvega, ihaskell, stdenv, text }:+mkDerivation {+ pname = "ihaskell-hvega";+ version = "0.1.0.0";+ src = ./.;+ libraryHaskellDepends = [ aeson base hvega ihaskell text ];+ homepage = "https://github.com/githubuser/ihaskell-hvega#readme";+ description = "IHaskell display instance for hvega types";+ license = stdenv.lib.licenses.bsd3;+}
ihaskell-hvega.cabal view
@@ -1,8 +1,9 @@ name: ihaskell-hvega-version: 0.1.0.0+version: 0.1.0.1 synopsis: IHaskell display instance for hvega types. description: Support Vega-Lite visualizations in IHaskell notebooks.-homepage: https://github.com/githubuser/ihaskell-hvega#readme+homepage: https://github.com/DougBurke/hvega+bug-reports: https://github.com/DougBurke/hvega/issues license: BSD3 license-file: LICENSE author: Douglas Burke@@ -11,13 +12,16 @@ category: Development build-type: Simple extra-source-files: README.md+ CHANGELOG.md+ stack.yaml+ default.nix cabal-version: >=1.10 library- hs-source-dirs: .+ hs-source-dirs: src exposed-modules: IHaskell.Display.Hvega build-depends: base >= 4.7 && < 5- , aeson >= 0.11 && < 1.3+ , aeson >= 0.11 && < 1.4 , hvega < 0.2 , ihaskell >= 0.6.2 , text == 1.2.*@@ -27,4 +31,4 @@ source-repository head type: git- location: https://github.com/githubuser/ihaskell-hvega+ location: https://github.com/DougBurke/hvega
+ src/IHaskell/Display/Hvega.hs view
@@ -0,0 +1,75 @@+{-# LANGUAGE OverloadedStrings #-}++module IHaskell.Display.Hvega where++import qualified Data.Text.Lazy as LT++import Data.Aeson.Text (encodeToLazyText)+import Data.Monoid ((<>))++import Graphics.Vega.VegaLite (VegaLite, fromVL)++import IHaskell.Display (IHaskellDisplay(..), Display(..), javascript)+++-- ^ Use <https://vega.github.io/vega-lite/usage/embed.html Vega-Embed>+-- to include the Vega-Lite visualization in an IHaskell notebook.+--+-- There is currently no way to pass+-- <https://github.com/vega/vega-embed#options options>+-- to the @vegaEmbed@ call.+--+-- Note that local file access is __not__ guaranteed to work - e.g.+-- @dataFromUrl@ where the file name refers to a local file -+-- since the JavaScript @fs@ module may not be loaded.+--+instance IHaskellDisplay VegaLite where+ display vl = + + let -- Note: need to look in the package.json files for these packages+ -- to find the "full name" (the contents of the jsdelivr key),+ -- since requirejs does seem to like appending .js to everything.+ --+ jsname n v = "'https://cdn.jsdelivr.net/npm/"+ <> n+ <> "@" <> v+ <> "/build/"+ <> n <> ".min'"++ -- Should the config be set on require or requirejs?+ --+ -- These versions are known to work; later versions+ -- do not work but I have not tried to work out the+ -- latest version that does work.+ --+ config = "requirejs({paths:{vg:" <> jsname "vega" "3.2.1"+ <> ",vl:" <> jsname "vega-lite" "2.3.0"+ <> ",vge:" <> jsname "vega-embed" "3.5.2"+ <> "},shim:{vge:{deps:['vg.global','vl.global']}"+ <> ",vl:{deps:['vg']}"+ <> "}});"+ <> "define('vg.global',['vg'],function(g){window.vega = g;});"+ <> "define('vl.global',['vl'],function(g){window.vl = g;});"++ -- rely on the element variable being set up; it appears to be an array+ -- so use the first element to add the div to.+ makeDiv = "var ndiv = document.createElement('div');"+ <> "ndiv.innerHTML = "+ <> "'Awesome Vega-Lite visualization to appear here';"+ <> "element[0].appendChild(ndiv);"+ + js = LT.unpack (encodeToLazyText (fromVL vl))++ -- Use the div element we have just created for the plot.+ -- More options could be passed to vegaEmbed.+ --+ plot = "require(['vge'],function(vegaEmbed){"+ <> "vegaEmbed(ndiv," <> js <> ").then("+ <> "function (result) { console.log(result); }).catch("+ <> "function (error) { ndiv.innerHTML = "+ <> "'There was an error: ' + error; });"+ <> "});"+ + ds = [javascript (config <> makeDiv <> plot)]+ + in pure (Display ds)
+ stack.yaml view
@@ -0,0 +1,8 @@+flags: {}++packages:+- .++extra-deps: []++resolver: lts-11.19