hvega 0.2.1.0 → 0.3.0.0
raw patch · 4 files changed
+52/−10 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Graphics.Vega.VegaLite: ChFill :: Channel
+ Graphics.Vega.VegaLite: ChStroke :: Channel
+ Graphics.Vega.VegaLite: tooltips :: [[TextChannel]] -> BuildLabelledSpecs
Files
- CHANGELOG.md +11/−0
- default.nix +1/−1
- hvega.cabal +2/−2
- src/Graphics/Vega/VegaLite.hs +38/−7
CHANGELOG.md view
@@ -1,6 +1,17 @@ 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.3.0.0++The `Channel` type has been extended to include `ChFill` and `ChStroke`+constructors and the `tooltips` function allows you to provide+multiple tooltips for a channel. The schema version has been changed+from 2 to 3, but there has been limited checking to see if the API+correctly reflects the new schema.++This functionality was provided by Adam Massmann (massma) and+BinderDavid.+ ## 0.2.1.0 Added the `toHtml` and `toHtmlFile` functions which create the necessary
default.nix view
@@ -1,7 +1,7 @@ { mkDerivation, aeson, base, stdenv, text, vector }: mkDerivation { pname = "hvega";- version = "0.2.0.0";+ version = "0.3.0.0"; src = ./.; libraryHaskellDepends = [ aeson base text vector ]; homepage = "https://github.com/DougBurke/hvega";
hvega.cabal view
@@ -1,6 +1,6 @@ name: hvega-version: 0.2.1.0-synopsis: Create Vega-Lite visualizations in Haskell.+version: 0.3.0.0+synopsis: Create Vega-Lite visualizations (version 3) in Haskell. description: This is an almost-direct port of elm-vega (<http://package.elm-lang.org/packages/gicentre/elm-vega/2.2.1>) to Haskell.
src/Graphics/Vega/VegaLite.hs view
@@ -14,17 +14,19 @@ <http://package.elm-lang.org/packages/gicentre/elm-vega/2.2.1/VegaLite Elm Vega Lite module> (version 2.2.1). It allows users to create a Vega-Lite specification, targeting-version 2 of the <https://vega.github.io/schema/vega-lite/v2.json JSON schema>.+version 3 of the <https://vega.github.io/schema/vega-lite/v3.json JSON schema>. The ihaskell-hvega module provides an easy way to embed Vega-Lite visualizations in an IHaskell notebook (using <https://vega.github.io/vega-lite/usage/embed.html Vega-Embed>). -The major change to version 2.2.1 of the Elm version is that the type representing+The major changes to version 2.2.1 of the Elm version is that the type representing the full Vega-Lite specification - that is, the return value of 'toVegaLite' - is not a 'VLSpec' (an alias for 'Data.Aeson.Value') but is instead a newtype around this ('VegaLite'). There are also some minor changes to the exported types and symbols (e.g. 'Utc' is exported rather than-@utc@ and @bin@ is not exported).+@utc@ and @bin@ is not exported). As time goes on there are more+changes (in particular the Elm module is being updated much-more rapidly+than this is). Note that this module exports several symbols that are exported by the Prelude, namely 'filter', 'lookup',@@ -69,7 +71,7 @@ @ > 'A.encode' $ 'fromVL' vl1-> "{\"mark\":{\"color\":\"teal\",\"opacity\":0.4,\"type\":\"bar\"},\"data\":{\"values\":[{\"start\":\"2011-03-25\",\"count\":23},{\"start\":\"2011-04-02\",\"count\":45},{\"start\":\"2011-04-12\",\"count\":3}],\"format\":{\"parse\":{\"start\":\"date:'%Y-%m-%d'\"}}},\"$schema\":\"https://vega.github.io/schema/vega-lite/v2.json\",\"encoding\":{\"x\":{\"field\":\"start\",\"type\":\"temporal\",\"axis\":{\"title\":\"Inception date\"}},\"y\":{\"field\":\"count\",\"type\":\"quantitative\"}},\"background\":\"white\",\"description\":\"A very exciting bar chart\"}"+> "{\"mark\":{\"color\":\"teal\",\"opacity\":0.4,\"type\":\"bar\"},\"data\":{\"values\":[{\"start\":\"2011-03-25\",\"count\":23},{\"start\":\"2011-04-02\",\"count\":45},{\"start\":\"2011-04-12\",\"count\":3}],\"format\":{\"parse\":{\"start\":\"date:'%Y-%m-%d'\"}}},\"$schema\":\"https://vega.github.io/schema/vega-lite/v3.json\",\"encoding\":{\"x\":{\"field\":\"start\",\"type\":\"temporal\",\"axis\":{\"title\":\"Inception date\"}},\"y\":{\"field\":\"count\",\"type\":\"quantitative\"}},\"background\":\"white\",\"description\":\"A very exciting bar chart\"}" @ The produced JSON can then be processed with vega-lite, which renders the following image :@@ -215,6 +217,7 @@ , text , tooltip+ , tooltips , TextChannel(..) -- ** Hyperlink Channels@@ -530,7 +533,7 @@ type VLSpec = Value vlSchemaName :: T.Text-vlSchemaName = "https://vega.github.io/schema/vega-lite/v2.json"+vlSchemaName = "https://vega.github.io/schema/vega-lite/v3.json" {-| @@ -558,6 +561,9 @@ in toVegaLite [ dat [], mark Bar [], enc [] ] @++The schema used is <https://github.com/vega/schema version 3 of Vega-Lite>.+ -} toVegaLite :: [(VLProperty, VLSpec)] -> VegaLite toVegaLite vals =@@ -2870,6 +2876,8 @@ | ChX2 | ChY2 | ChColor+ | ChFill+ | ChStroke | ChOpacity | ChShape | ChSize@@ -2881,6 +2889,8 @@ channelLabel ChX2 = "x2" channelLabel ChY2 = "y2" channelLabel ChColor = "color"+channelLabel ChFill = "fill"+channelLabel ChStroke = "stroke" channelLabel ChOpacity = "opacity" channelLabel ChShape = "shape" channelLabel ChSize = "size"@@ -4504,7 +4514,7 @@ encoding . position X [ PName "miles", PmType Quantitative ] . position Y [ PName "gas", PmType Quantitative ]- . text [ TName "miles", TmType Quantitative ]+ . text [ 'TName' "miles", 'TmType' Quantitative ] @ -} text ::@@ -4561,7 +4571,7 @@ enc = encoding . position X [ PName \"Horsepower\", PmType Quantitative ] . position Y [ PName \"Miles_per_Gallon\", PmType Quantitative ]- . tooltip [ TName \"Year\", TmType Temporal, TFormat "%Y" ]+ . tooltip [ 'TName' \"Year\", 'TmType' 'Temporal', 'TFormat' "%Y" ] @ -} tooltip ::@@ -4570,3 +4580,24 @@ -> BuildLabelledSpecs tooltip tDefs ols = ("tooltip" .= object (concatMap textChannelProperty tDefs)) : ols++{-|++Encode a tooltip channel with multiple tooltips.+The first parameter is a list of the multiple tooltips, each of which is a list of text+channel properties that define the channel.++@+enc = encoding+ . position X [ PName \"Horsepower\", PmType Quantitative ]+ . position Y [ PName \"Miles_per_Gallon\", PmType Quantitative ]+ . tooltips [ [ 'TName' \"Year\", 'TmType' 'Temporal', 'TFormat' "%Y" ]+ ,[ TName \"Month\", TmType Temporal, TFormat "%Y" ] ]+@+-}+tooltips ::+ [[TextChannel]]+ -- ^ A separate list of properties for each channel.+ -> BuildLabelledSpecs+tooltips tDefs ols =+ ("tooltip" .= toJSON (map (object . (concatMap textChannelProperty)) tDefs)) : ols