packages feed

hvega 0.4.1.0 → 0.4.1.1

raw patch · 7 files changed

+95/−32 lines, 7 filesdep ~containersPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependency ranges changed: containers

API changes (from Hackage documentation)

+ Graphics.Vega.Tutorials.VegaLite: skyPlot2 :: VegaLite

Files

CHANGELOG.md view
@@ -1,6 +1,12 @@ For the latest version of this document, please see [https://github.com/DougBurke/hvega/blob/master/hvega/CHANGELOG.md](https://github.com/DougBurke/hvega/blob/master/hvega/CHANGELOG.md). +## 0.4.1.1++Avoid a build warning about importing <> from Data.Monoid in GHC 8.8.1+by using the CPP sledge-hammer. Relaxed the bounds on containers so+that the tests can be built on stack LTS 9.21 (GHC 8.0.2).+ ## 0.4.1.0  Updated the tutorial, adding in a new plot to introduce the addition
README.md view
@@ -1,13 +1,25 @@ # hvega -Support the creation of [Vega-Lite](https://vega.github.io/vega-lite/) visualizations-in Haskell. This code is released under the BSD3 license.+Create [Vega-Lite](https://vega.github.io/vega-lite/) visualizations in+Haskell. It targets version 3 of the Vega-Lite specification. Note that+the module does not include a viewer for these visualizations (which are+JSON files), but does provide several helper functions, such as+[toHtmlFile](https://hackage.haskell.org/package/hvega/docs/Graphics-Vega-VegaLite.html#v:toHtmlFile),+which create HTML that can be viewed+with a browser to display the visualization. Other approaches include+automatic display in IHaskell notebooks - with the+[ihaskell-vega](https://hackage.haskell.org/package/ihaskell-hvega)+package - or use of external viewers such as+[Vega View](https://hackage.haskell.org/package/vega-view) and+[Vega-Desktop](https://github.com/vega/vega-desktop). -It is an almost-direct copy of version 2.2.1 of the+It is based on an early version (2.2.1) of the [Elm Vega library](http://package.elm-lang.org/packages/gicentre/elm-vega/2.2.1/VegaLite), which is released under a BSD3 license by Jo Wood of the giCentre at the City University of London. +This code is released under the BSD3 license.+ ## Example  ```Haskell@@ -29,12 +41,19 @@  ## Documentation -The [Elm Vega documentation](http://package.elm-lang.org/packages/gicentre/elm-vega/2.2.1)-can be used as a guide to using this module. The+A tutorial is provided as part of the module: it is based, as is+so much of the module, on the+[Elm Vega walk through](https://github.com/gicentre/elm-vegalite/tree/master/docs/walkthrough).+The tutorial+is [available on hackage](https://hackage.haskell.org/package/hvega/docs/Graphics-Vega-Tutorials-VegaLite.html) - and includes the plot outputs -+and the plots it creates are also available by importing the+`Graphics.Vega.Tutorials.VegaLite` module.++The [Vega-Lite Example Gallery](https://vega.github.io/vega-lite/examples/) has been converted to an [IHaskell notebook](https://github.com/DougBurke/hvega/blob/master/notebooks/VegaLiteGallery.ipynb)-Uunfortunately the plots created by VegaEmbed **do not appear**+Uunfortunately the plots created by VegaEmbed **do not always appear** in the notebook when viewed with either GitHub's viewer or [ipynb viewer](http://nbviewer.jupyter.org/github/DougBurke/hvega/blob/master/notebooks/VegaLiteGallery.ipynb), but things seem much better when using Jupyter Lab (rather than@@ -50,22 +69,15 @@  ## Differences to Elm Vega -The main changes to version 2.2.1 of-[Elm Vega](http://package.elm-lang.org/packages/gicentre/elm-vega/2.2.1)-are:--- Replace `Spec` by `VLSpec` (although both are synonyms for the underlying-  JSON representation).--- Add a type for the output of `toVegaLite` (`VegaLite`) that is separate from-  `VLSpec`, which is usefull for integration with IHaskell. The JSON-  specification is retrieved with `fromVL`.--- Take advantage of the lack of backwards compatibality requirements to remove or-  replace several symbols (such as add the `Utc` constructor to `TimeUnit`, remove the `bin`-  function, and use `Data` rather than `(VLProperty, VLSpec)` in function-  signatures).+Elm Vega has changed significantly since I started `hvega`, and no-longer+exposes data types directly but uses functions instead: for example,+rather than `PName`, it uses a function like `pName`. It is an open+question whether `hvega` will make the same switch. Over time+the naming of certain operations or data types has diverged between+`hevga` and Elm Vega. -- In version 0.2.0.0, the constructors for the `LegendOrientation` type-  have gained a `LO` prefix, which avoids clashing with the Prelude's-  `Either` type.+One of the more-obvious changes is that the output of `toVegaLite`+is a separate type from the input values - that is `VegaLite`+and `VLSpec` - since it makes it easier to display the output of+`hvega` in `IHaskell`. The JSON specification is retrieved from+this type with `fromVL`.
hvega.cabal view
@@ -1,5 +1,5 @@ name:                hvega-version:             0.4.1.0+version:             0.4.1.1 synopsis:            Create Vega-Lite visualizations (version 3) in Haskell. description:         This is based on the elm-vegalite package                      (<http://package.elm-lang.org/packages/gicentre/elm-vegalite/latest>)@@ -178,7 +178,7 @@                      , aeson-pretty == 0.8.*                      , base >= 4 && < 5                      , bytestring == 0.10.*-                     , containers >= 0.5.8 && < 0.7+                     , containers >= 0.5.7 && < 0.7                      , filepath                      , tasty                      , tasty-golden >= 2.2 && < 2.4
src/Graphics/Vega/Tutorials/VegaLite.hs view
@@ -123,6 +123,7 @@   , posPlot    , skyPlot+  , skyPlot2  -- DEBUG    -- * Layered and Multi-View Compositions   --@@ -1320,6 +1321,45 @@                 , trans []                 , mark Circle []                 , enc []+                ]++skyPlot2 :: VegaLite+skyPlot2 =+  let enc = encoding+              . position Longitude (axOpts "fakeLongitude")+              . position Latitude (axOpts "DE_ICRS")+              . color [ MName "plx"+                      , MmType Quantitative+                      , MScale [ SType ScLog+                               , SScheme "viridis" []+                               ]+                      ]+              . tooltip [ TName "Cluster", TmType Nominal ]+                    +      axOpts field = [ PName field, PmType Quantitative ]+            +      trans = transform+                . calculateAs "180 - datum.RA_ICRS" "fakeLongitude"++      spec1 = [ gaiaData+              , trans []+              , enc []+              , mark Circle []+              ]++      -- depending on how we view it, may need to specify mark+      -- options (ie "mark Geoshape []" should be enough but+      -- vega-view doesn't show anything for some reason, but+      -- the vega editor does)+      --+      spec2 = [ graticule [ GrStepMinor (45, 20) ]+              , mark Geoshape [ MFilled False, MStrokeWidth 0.3 ]+              ]+      +  in toVegaLite [ projection [ PrType Mercator+                             , PrCenter 0 0+                             ]+                , layer [ asSpec spec1, asSpec spec2 ]                 ]  -- $intro-layered
src/Graphics/Vega/VegaLite.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} {-# OPTIONS_GHC -fwarn-incomplete-patterns #-}@@ -9,7 +10,7 @@  Maintainer  : dburke.gw@gmail.com Stability   : unstable-Portability : OverloadedStrings, TupleSections+Portability : CPP, OverloadedStrings, TupleSections  This is a port of the <http://package.elm-lang.org/packages/gicentre/elm-vegalite/latest Elm Vega Lite module>,@@ -618,7 +619,10 @@ -- Aeson's Value type conflicts with the Number type import Data.Aeson (Value, decode, encode, object, toJSON, (.=)) import Data.Maybe (catMaybes, fromMaybe, mapMaybe)++#if !(MIN_VERSION_base(4, 12, 0)) import Data.Monoid ((<>))+#endif  -- added in base 4.8.0.0 / ghc 7.10.1 import Numeric.Natural (Natural)@@ -1586,7 +1590,7 @@     , "<body>"     , "<div id=\"vis\"></div>"     , "<script type=\"text/javascript\">"-    , ("  var spec = " <> spec <> ";")+    , "  var spec = " <> spec <> ";"     , "  vegaEmbed(\'#vis\', spec" <> opts <> ").then(function(result) {"     , "  // Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view"     , "  }).catch(console.error);"@@ -6580,7 +6584,7 @@ selectionProperty (SInitInterval Nothing Nothing) = "init" .= A.Null selectionProperty (SInitInterval mx my) =   let conv (_, Nothing) = Nothing-      conv (lbl, (Just (lo, hi))) = Just (lbl .= [ dataValueSpec lo, dataValueSpec hi ])+      conv (lbl, Just (lo, hi)) = Just (lbl .= [ dataValueSpec lo, dataValueSpec hi ])    in "init" .= object (mapMaybe conv (zip ["x", "y"] [mx, my])) @@ -7974,7 +7978,7 @@         RLegend chRules -> ("legend", chRules)         RScale chRules -> ("scale", chRules) -      ans = map (\(ch, rule) -> (channelLabel ch .= resolutionLabel rule)) rls+      ans = map (\(ch, rule) -> channelLabel ch .= resolutionLabel rule) rls   in (nme, object ans)  @@ -10295,7 +10299,7 @@   -- ^ A separate list of properties for each channel.   -> BuildLabelledSpecs tooltips tDefs ols =-  ("tooltip" .= toJSON (map (object . (concatMap textChannelProperty)) tDefs)) : ols+  ("tooltip" .= toJSON (map (object . concatMap textChannelProperty) tDefs)) : ols   -- | This is used with 'MTooltip'.
stack.yaml view
@@ -5,4 +5,4 @@  extra-deps: [] -resolver: lts-14.4+resolver: lts-14.7
tools/PlayTutorial.hs view
@@ -100,6 +100,7 @@      , ("pointplot", VL.pointPlot)      , ("posplot", VL.posPlot)      , ("skyplot", VL.skyPlot)+     , ("skyplot2", VL.skyPlot2)      , ("smallmultiples", VL.smallMultiples)      , ("smallmultiples2", VL.smallMultiples2)      , ("baseplot", VL.basePlot)