hvega 0.10.0.0 → 0.11.0.0
raw patch · 34 files changed
+1216/−242 lines, 34 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Graphics.Vega.Tutorials.VegaLite: stripPlotWithColor2 :: VegaLite
+ Graphics.Vega.VegaLite: DMax :: Double -> ScaleDomain
+ Graphics.Vega.VegaLite: DMaxTime :: [DateTime] -> ScaleDomain
+ Graphics.Vega.VegaLite: DMid :: Double -> ScaleDomain
+ Graphics.Vega.VegaLite: DMin :: Double -> ScaleDomain
+ Graphics.Vega.VegaLite: DMinTime :: [DateTime] -> ScaleDomain
+ Graphics.Vega.VegaLite: MNullValue :: MarkChannel
+ Graphics.Vega.VegaLite: OBand :: Double -> OrderChannel
+ Graphics.Vega.VegaLite: ODataCondition :: [(BooleanOp, [OrderChannel])] -> [OrderChannel] -> OrderChannel
+ Graphics.Vega.VegaLite: ONoTitle :: OrderChannel
+ Graphics.Vega.VegaLite: ONumber :: Double -> OrderChannel
+ Graphics.Vega.VegaLite: OSelectionCondition :: BooleanOp -> [OrderChannel] -> [OrderChannel] -> OrderChannel
+ Graphics.Vega.VegaLite: OTitle :: Text -> OrderChannel
+ Graphics.Vega.VegaLite: RField :: FieldName -> ScaleRange
+ Graphics.Vega.VegaLite: RMax :: Double -> ScaleRange
+ Graphics.Vega.VegaLite: RMin :: Double -> ScaleRange
+ Graphics.Vega.VegaLite: SDomainOpt :: ScaleDomain -> ScaleProperty
+ Graphics.Vega.VegaLite: data DomainLimits
- Graphics.Vega.VegaLite: DDateTimes :: [[DateTime]] -> ScaleDomain
+ Graphics.Vega.VegaLite: DDateTimes :: [[DateTime]] -> DomainLimits
- Graphics.Vega.VegaLite: DNumbers :: [Double] -> ScaleDomain
+ Graphics.Vega.VegaLite: DNumbers :: [Double] -> DomainLimits
- Graphics.Vega.VegaLite: DStrings :: [Text] -> ScaleDomain
+ Graphics.Vega.VegaLite: DStrings :: [Text] -> DomainLimits
- Graphics.Vega.VegaLite: DUnionWith :: ScaleDomain -> ScaleDomain
+ Graphics.Vega.VegaLite: DUnionWith :: DomainLimits -> ScaleDomain
- Graphics.Vega.VegaLite: SDomain :: ScaleDomain -> ScaleProperty
+ Graphics.Vega.VegaLite: SDomain :: DomainLimits -> ScaleProperty
Files
- CHANGELOG.md +48/−4
- README.md +9/−10
- default.nix +1/−1
- hvega.cabal +5/−1
- hvega.nix +1/−1
- shell.nix +1/−1
- src/Graphics/Vega/Tutorials/VegaLite.hs +100/−100
- src/Graphics/Vega/VegaLite.hs +58/−9
- src/Graphics/Vega/VegaLite/Core.hs +114/−31
- src/Graphics/Vega/VegaLite/Data.hs +4/−4
- src/Graphics/Vega/VegaLite/Input.hs +2/−3
- src/Graphics/Vega/VegaLite/Legend.hs +2/−2
- src/Graphics/Vega/VegaLite/Scale.hs +120/−27
- src/Graphics/Vega/VegaLite/Time.hs +5/−1
- tests/CompositeTests.hs +6/−6
- tests/ConditionalTests.hs +49/−0
- tests/DataTests.hs +1/−1
- tests/EncodingTests.hs +24/−0
- tests/Gallery/Bar.hs +51/−16
- tests/Gallery/Facet.hs +71/−1
- tests/Gallery/Geo.hs +1/−1
- tests/Gallery/Line.hs +1/−1
- tests/Gallery/Multi.hs +3/−3
- tests/MarkTests.hs +43/−0
- tests/ScaleTests.hs +31/−8
- tests/specs/conditional/selectionHeatMap.vl +120/−0
- tests/specs/gallery/bar/bar6order.vl +27/−0
- tests/specs/gallery/bar/bar6sort.vl +31/−0
- tests/specs/gallery/facet/facet_bullet.vl +189/−0
- tests/specs/gallery/geo/geo7.vl +1/−2
- tests/specs/gallery/line/line7.vl +1/−2
- tests/specs/scale/axislimit.vl +40/−0
- tests/specs/scale/namedaxisrange.vl +33/−0
- tools/PlayTutorial.hs +23/−6
CHANGELOG.md view
@@ -1,6 +1,50 @@ 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.11.0.0++The Vega-Lite tests are now validated against version 4.15 of the+Vega-Lite schema.++Note that `hvega` does __not__ provide any information to help users+take advantage of the (new to 4.14) ability to omit the type of a+field when [it can be inferred](https://vega.github.io/vega-lite/docs/type.html).+As the type is currently optional in `hvega` users can just not give a type.+The example [IHaskell notebooks](https://github.com/DougBurke/hvega/tree/master/notebooks)+have been updated to show off the optional support.++Similarly, Vega-Lite 4.14 allows you to share the type, scale, axis,+and legend in a shared encoding. There is no explicit support added in+0.11.0.0 because `hvega` already allowed you to create the specification.++### New Constructors++The `OrderChannel` type has gained `OBand`, `OTitle`/`ONoTitle`,+and conditional-predicate support with `ODataCondition`,+`OSelectionCondition`, and `ONumber` constructors.++The `MarkChannel` type has gained the `MNullValue` constructor.++The `ScaleRange` type has gained `RField`, `RMax`, and `RMin`+constructors.++### Breaking Changes++Domain settings in `ScaleProperty` and associated types have been+changed to better match the Vega-Lite schema: `SDomain` now takes+a new type (`DomainLimits`) which actually contains many of the+orignal symbols (so hopefully will require no changes), and a new+constructor has been added (`SDomainOpt`) which takes the+`ScaleDomain` type, which has seen new constructors - `DMax`,+`DMaxTime`, `DMid`, `DMin`, and `DMinTime` - as well as+some constructors moving to `DomainLimits`.++### Deprecated symbols++The `SDomainMid` constructor of `ScaleProperty` will be removed in a+future release as it has been replaced by the `DMid` constructor+in `ScaleDomain`.+ ## 0.10.0.0 The Vega-Lite tests are now validated against version 4.13 of the@@ -21,7 +65,7 @@ Month` has been changed to `PTimeUnit (TU Month)` and `SNice NMinute` has changed to `SNice (NTU NMinute)`. -The `BaseTimeUnit' type has seen a number of additions: the `Week` and+The `BaseTimeUnit` type has seen a number of additions: the `Week` and `DayOfYear` time units added in Vega-Lite 4.13.0, along with the associated composite units (such as `YearWeek`), and a number of composite types that were missing (such as `MonthDateHours`). The@@ -62,7 +106,7 @@ The `angle` encoding channel has been added for text and point marks. The `Channel` type has gained `ChAngle`, `ChTheta`, `ChTheta2`,-`ChRadius`, `ChRadius`', 'ChDescription', and `ChURL`.+`ChRadius`, `ChRadius`, `ChDescription`, and `ChURL`. Layers have been added to `Arrangement` (`Layer`) and to `RepeatFields` (`LayerFields`).@@ -830,7 +874,7 @@ optional field name, to allow them to be used as part of an encoding aggregation (e.g. with `PAggregate`). -The "z index" value has changed from an 'Int' to the 'ZIndex' type.+The "z index" value has changed from an `Int` to the `ZIndex` type. The constructors for the `Symbol` type now all start with `Sym`, so `Cross`, `Diamond`, `TriangleUp`, `TriangleDown`, and `Path` have been@@ -838,7 +882,7 @@ `SymTriangleDown`, and `SymPath`, respectively. The `Legend` type has been renamed `LegendType` and its constructors-have been renamed 'GradientLegend' and 'SymbolLegend'.+have been renamed `GradientLegend` and `SymbolLegend`. ### Improved testing
README.md view
@@ -1,9 +1,9 @@ # hvega -[](https://vega.github.io/vega-lite/)+[](https://vega.github.io/vega-lite/) Create [Vega-Lite](https://vega.github.io/vega-lite/) visualizations in-Haskell. It targets version 4.13 of the Vega-Lite specification. Note that+Haskell. It targets version 4.15 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),@@ -39,7 +39,7 @@ enc = encoding . position X [ PName "Horsepower", PmType Quantitative ] . position Y [ PName "Miles_per_Gallon", PmType Quantitative, PTitle "Miles per Gallon" ]- . color [ MName "Origin", MmType Nominal ]+ . color [ MName "Origin" ] bkg = background "rgba(0, 0, 0, 0.05)" @@ -48,7 +48,7 @@ When the JSON is viewed with a Vega-Lite aware viewer, the resultant plot can be interacted with (e.g. to use the tooltip support) using the-[interactive version](https://vega.github.io/editor/#/url/vega-lite/N4IgtghgTg1iBcoAuB7FAbJBLADg0AxigHZICmpCIFRAJlsQOYgC+ANCEgJ45lUFYoBdH3YhaEJBHwgArlHRUAFkiQ4AzvAD0WgG5lGEAHSMsSJbIBGRrCj0GIAWglT1ZJOq0uIWgtHVGAFbqJKwcACTqBEpkkMqqGtr2hiZmFta2WlExkMlO6GZkegAsQSHEIBw0KPRMMkToKFAyAGZYZOi0VADyUFimFRzcvFTEKGAMEIpiAB6t7Z1UABJNbjgoAO5kzUM8fPAgAI6yEKRmklj6YSBc8x1dBwCyWCLqAPq8UG8A4lONg5wzCIqM9XgACT5g37of6VTh7KjHU7YKTYK4sMSWCAEGCMKAoWTEB4gKCMLEACgADGxqbSjJSAKwASlYQA).+[interactive version](https://vega.github.io/editor/#/url/vega-lite/N4IgtghgTg1iBcoAuB7FAbJBLADg0AxigHZICmpCIFRAJlsQOYgC+ANCEgJ45lUFYoBdH3YhaEJBHwgArlHRUAFkiQ4AzvAD0WgG5lGEAHSMsSJbIBGRrCj0GIAWglT1ZJOq0uIWgtHVGAFbqJKwcACTqBEpkkMqqGtr2hiZmFta2WlExkMlO6GZkegAsQSHEIBw0KPRMMkToKFAyAGZYZOi0VADyUFimFWIAHq3tnVQAEk1uOCgA7mTNHNy8VACOshCkZpJY+mEgXKMdXfAgALJYIuoA+rxQNwDiEOiNFctmIlSX1wAE979nq9QsseHwzhsttgpNh9iwxJYIAQYIwoChZMRTiAoIxEQAKAAMbF+RJJxIJRgJAFYAJSsIA). It can also be viewed as a PNG: @@ -76,12 +76,12 @@ w = width 600 h = height 150 - pos1Opts fld ttl = [PName fld, PmType Quantitative, PAxis [AxTitle ttl]]+ pos1Opts fld ttl = [PName fld, PmType Quantitative, PTitle ttl] x1Opts = pos1Opts "days" "Days since January 1, 2020" y1Opts = pos1Opts "magnitude" "Magnitude" ++ [PSort [Descending], yRange] yRange = PScale [SDomain (DNumbers [-1, 3])] - filtOpts = [MName "filterName", MmType Nominal]+ filtOpts = [MName "filterName"] filtEnc = color (MLegend [ LTitle "Filter", LTitleFontSize 16, LLabelFontSize 14 ] : filtOpts) . shape filtOpts @@ -93,8 +93,8 @@ . filtEnc selName = "brush"- pos2Opts fld = [PName fld, PmType Quantitative, PAxis [AxNoTitle],- PScale [SDomain (DSelectionField selName fld)]]+ pos2Opts fld = [PName fld, PmType Quantitative, PNoTitle,+ PScale [SDomainOpt (DSelectionField selName fld)]] x2Opts = pos2Opts "days" y2Opts = pos2Opts "magnitude" ++ [PSort [Descending]] @@ -132,7 +132,6 @@ details = asSpec [ columns 1 , facetFlow [ FName "filterName"- , FmType Nominal , FHeader headerOpts ] , spacing 10@@ -155,7 +154,7 @@ This can be viewed as - - an [interactive version](https://vega.github.io/editor/#/url/vega-lite/N4KABGBEAuBOCGA7AzgMwPawLaQFxgG1wIxhJUBLAG2gFNY8oATeaAVywDpKb6A5eFloEADAF0wAXmlgA5ADVZkAL4AaYhDI86DfJBbsuWeAHNEFdk1pgAPGAAsK9SVKR4yRvvgBPD6qgAxvBUAWxUrLSeBhycAFZMYAC0YABM9gCsAByZ9gCcnCIqxGLOgeiIlCaMoC5uAB4UHvg1LlDQFlS0AGLl0ADqtBQmABbQnoiYxlSQpbXhAEa0VD2I0ADKFABekfgAjPazJDAd3b0b24y7AGwaYMrEasRe0PDVt5BssNN6o9AADshcAB6IEIADunBMFmGbHmbGQ9ACvVoq04SKwQIAIug2CYAEKfADWtCBwwAbrQTPAgcZkDpSRSqUCDNTFnQqCZaPDaIkUiI+YkRABmRK7fKxZDlSAPUqQMlIxBBMb4IguFq1YaDEbKsC7dIiQ4QSDGWCE6qQdB-eABCzeRgiTjpfwwbx-HZQP7oCirGZQHidJiMVDBBGPVpQMEUJjQYaMK4iA23I0IzoBdpS5pJo7zWDw2OZ8O1b0Wc11RgEXl8-y7BMlKB2lWCx3+FKOsRhwtGlFIpjekxNQiQMvOu0lLO1aCu92Qb06MnBaWd+7hju1bvoXuIKoFwuQJFUTBvTtGyhLQN6bT8QSRQ2tF1u8boLDehe3uaUlHn0jju8LJYrdYtndfY3zvdpoE6TwumoHQZh-CcTgA85gJuY87h-Vc72QYZ4AfZpyAoM9PEvWABCEX172nCZn0QBdMNqMsd07AiiL0FhfDgtDKM8ABHNgkHA1gKApTjj3qRpzXAyC9ExHxkDAZBvQCawACkkH42BvF1Ft+UKZdC3oo4G2-LjTyoL9jVMcxLBveCoGQIJpNcJgn3gb1y1FfwhXbUDk0wHV9FoBzPz7UTmMnPCoD4gSLCEkTfKgeAGgHMgpOnABZKyLDYKwiiXLN9IgTD1SOZA3QCI9d01IZRkufVQMs01zUta1bXtZs2inTxPVnCj-VoL9gyoUMGsjaN8zAeNE2Y9dN23EyxP3Q8mLEsyLJIsjbLQo0Iqop8X2mBKjU6TlEC-EquL-ZYziAy4DjshCIOnaDeAYI6jjSpDbr2VDtsKgyEsgbDcPdLRCPM4iYKvcjnV2x8aLowHGIW0zwYs9i-Ae+zHNB-RXPc-C1qiOSKJTWg0woDMoBzPMVEM8NuL0aLVli9p4qx8SUuOJ7GEQMIqH+ldAeMi7dyJvRjDMbLcveoGcfNFzjAJ1xxagSXrJym97KWcn00QTwaewunZclWAAqsYKztC2W4aZ-iWZeNmtu2znJJOXn+cF1ovaKgrbz3dAqA4FBLn94NlJ1UWTzRyHXs2sK701eArF0FHdyugBBRVhmWqBPwThmroAUTqP5U8gWQXp0fBZDAABqMBoi4K6C9-eBFioAAFZO5sYXl7su9v-xui4fsBtKPaoKhAczqghn1vRYBqsYMIa22oGog7F29-2ytardLhEW59LHI0ABIHM1YxPF+AFgSBRl4EhaFYU4SmgUv2hjAfyl4ESOe6AP3sHESU+tZQTxWjAWgdQAp4loOyD83JZDyXVtLawQh3CfC-iiaAyB-D7nCHQBI8wtIZwzvINYAB5BO5AR7AUyDKJ4FsAhLz+HrTwAAJdAYIwA4XknA9knIkHyRzMvRAQV5LziXgNfw8x3ADTAOURurB4BgAIREYhpDyFULAAAClvoCEEYJjGcHgPAMkkpOCYBMECAAlJwMAABNHECkc5hASCGdAYADzoEJGAVgvDoD-EMUCaAkYgn0DRE+IEbIljzHQNAfxZ1AnBPvlCGMr90SkgoH8P4xIYnwLiQkhxABJRJYJ3D+KnmAGM1gECckUYgBS6AbTBDAEIXsqiAm1IUi8M2ijUCpF0pwaUyggA)+ - an [interactive version](https://vega.github.io/editor/#/url/vega-lite/N4IgLgTghgdgzgMwPYQLYgFwG1QIJYA2YAphJiACZRgCuqAdPkaQHJSrFYAMAugAQBeIXwDkANREgAvgBpchEmQyVqdeqigBzGHloVifADx8ALNLkgocclQCe1mSADGUAk5oFqxG6oYArCj4AWj4AJhMAVgAOKJMATnouaR5HJyQYfE1MUCgADzxrDFAwXQJiADF0sAB1YjxNAAswchgUDQIQR08AI2ICSpgwAGU8AC9vDABGE0cSsDKB4bGJyYA2KVkVMChskBoIDuUmsAAHOAwAegvoAHd6TV0Gmm6aOFI0weJB+jTUC4ARJA0TQAIX2AGtiBcGgA3YiaKAXDRwRTQuEIi5UbYXXokAiaYivYhBUJcUlBLgAZiCkwSfjg6XMIBhHxczWwoAadUa7MmES4jg0EHBuyQJygTl0tkwXHoEVmthOExAJyQeEGnRATDKFEwCFcb02NzwFDADUwqy4ApAbzKThKjKKIG6EFe5qd6t0u1ymCwJNJMkmVpSIGl2ApcpkoTlPE2XzSFHVmkKWBAPsc0pDYEVyvVihhrmkcZgCaTuzSBBQu3wfV1yiYijYHE1ZQJMDroB6fUWI3GmGms1KyvKClImrmCyqvZW602cAaUCV1bwtfIDdY7G8mx9TprBDrKns46H5H+UHsfDg6qcBgAUrAaFAILY+JMZGEyUkFUvlABHR+DLo1B4HCTJhvIq7KBo2i6DQ+ianALhlLsFBIBo6q+jSMiUrGjgMhA7KUMQiFfImMBZIO8zKgAsloOh6N437Kv+sBzMBoEbLIoBwEqTi7Fy9RNP2-KCk+IpOmKEpSjKkbgDm5CqnmmrasQdb6gQhqOMaprupa1rxkgZFZE6FZVruK77muo4QE2jEgK2pG7F2-RTss-YzOAJ7KCOzBkJRk6DNO-aznhC4-hBln1tZtlMjuEUHnYDg2khEygKh6EwMukGHkltrEPaeCOs6rrzkW-kTDAHgEEx5AsYB2wlBxGZZZFIDQfRcF2YhripZQaFQBh5nZe1sHwXhfT5Q6mXKC6bplTaKCEfoJHtmW5WYJVBDVXJP4gHVbGNVuGypEgBB0PA-aOPqN7svFVm+TFjhclA+hKJ2UC9AQACCJYNGZICOV0H19AAorkJxKCAIg+YoGCiHwADUfBYmozktsDBAAAovUZmAkh5zk9m5UyrOtGCbdtzlfQQ9TTSAECCc0x02uKkrkf2XBSCGAAkiFcho5DHGclwXOiUD3I8zz0IVFx88QGii-CUBBDTJCiyY9D0oyZPFMQuSESCxB4vChJvCIcB8CNDGW8QVj7PLXxgHA74Vp4JCBN0L5fV9YhDAA8sprl9lMUSbMtTgMycU3kAAEkgNx8AuFuG3iBJEubfAuozMDERbBYM6p77dFYql8OkyPUFAfCu14Htez7-t8AAFEL5xXDcHf0FAUAwgy9AoJoFwAJT0HwACaQKXn9HiBAaSB8JWSDgnw1CJ2ApxtxcYDGuvpA-GhOJG303RIGAK-tmvG8iw8ZpS780J4CcJyQofeIn2Ao8AJJnzcVgr1tfAzQGGgASMuMBLxIElK4G2iYq6ryAZebYBEy4IA-KSeg0ggA) - as a PNG:
default.nix view
@@ -1,2 +1,2 @@-{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883" }:+{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc884" }: nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./hvega.nix { }
hvega.cabal view
@@ -1,5 +1,5 @@ name: hvega-version: 0.10.0.0+version: 0.11.0.0 synopsis: Create Vega-Lite visualizations (version 4) in Haskell. description: This is based on the elm-vegalite package (<http://package.elm-lang.org/packages/gicentre/elm-vegalite/latest>)@@ -226,6 +226,8 @@ , tasty-golden >= 2.2 && < 2.4 , text == 1.2.* , unordered-containers >= 0.2 && < 0.3+ -- hvega is not needed with recent cabal's, but it's+ -- not obvious if this is true with older versions , hvega default-language: Haskell2010@@ -243,6 +245,8 @@ , bytestring , directory , filepath+ -- hvega is not needed with recent cabal's, but it's+ -- not obvious if this is true with older versions , hvega , text else
hvega.nix view
@@ -4,7 +4,7 @@ }: mkDerivation { pname = "hvega";- version = "0.10.0.0";+ version = "0.11.0.0"; src = ./.; configureFlags = [ "-ftools" ]; isLibrary = true;
shell.nix view
@@ -1,2 +1,2 @@-{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883" }:+{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc884" }: (import ./default.nix { inherit nixpkgs compiler; }).env
src/Graphics/Vega/Tutorials/VegaLite.hs view
@@ -19,7 +19,9 @@ <https://youtu.be/9uaHRWj04D4 Wongsuphasawat et al at the 2017 Open Vis Conf>. The tutorial targets version 4 of the Vega-Lite specification and-the functionality provided in version @0.9.0.0@ of hvega.+the functionality provided in version @0.11.0.0@ of hvega (although+a number of examples could be simplified by removing the+now-optional type information as of Vega-Lite 4.14). -} @@ -75,6 +77,7 @@ -- ** Adding color as an encoding , stripPlotWithColor+ , stripPlotWithColor2 -- ** Comparing Ordinal with Nominal data types --@@ -706,7 +709,47 @@ , enc [] ] +{-| +As of Vega-Lite version 4.14 we can now drop the type information when+it can be inferred. I am a little hazy of the rules, so I am going to+include the information (as it also means I don't have to change+the existing code!). However, as an example, we don't need to+add the @MmType Nominal@ setting to the 'color' channel, since the+following creates the same visualization as 'stripPlotWithColor':++<https://vega.github.io/editor/#/url/vega-lite/N4IgtghgTg1iBcIAuBLAxnANCAJhJECoArlADYIgAWSSADgM7wD0zUEA7gHQDmKSVYgCNiDAKZQ0AewB2SMXK7SwzACJTiPAEKkYY5lQBuYnhGaQG8qAeOnmeAs1MoIAWghuAbAEZP77wAMrgRCZGLeEFwyUq5UYhA4ElxIDIYg2ABmUlCQSEQgdNDi+QDikDyUMsRgQhLpIABKAIIA+gCSAMINAMqV1bVQ9XRkAB59NXXYqgCi7V29iFUTg9hiLcNji-11AL572AAkDGhxkJQ09EystpF8AsJcKFLMx6dmN65k-PqGACxcACsGLJ6gppDgUDIKvBQNIyNl8hkUGIyDhKB0yKIrCAdthNqAkSi0YgNvVUEgwpQAArQCBkMgQEYAAgAFBYAJRkgCedDElAAjsQIHJ+PgUMYcXsgA Open this visualization in the Vega Editor>++@+let enc = encoding+ . position X [ PName \"plx\", PmType Quantitative, 'PTitle' \"Parallax (mas)\" ]+ . 'color' [ 'MName' \"Cluster\" ]++in toVegaLite+ [ gaiaData+ , mark Tick []+ , enc []+ ]+@++Note that as well as removing @MmType Nominal@ from the 'color' encoding, I have+switched to the 'PTitle' option (which is the same as @PAxis [AxTitle ...]@.++-}++stripPlotWithColor2 :: VegaLite+stripPlotWithColor2 =+ let enc = encoding+ . position X [ PName "plx", PmType Quantitative, PTitle "Parallax (mas)" ]+ . color [ MName "Cluster" ]++ in toVegaLite+ [ gaiaData+ , mark Tick []+ , enc []+ ]++ -- $stripplot-mmtype -- It is instructive to see what happens if we change the mark type for -- the color encoding from 'Nominal' to 'Ordinal'.@@ -4069,7 +4112,8 @@ ] . position Y [ PName \"plx\" , PmType Quantitative- , PScale [ SDomain ('DSelection' \"brush\") ]+ -- prior to 0.11.0.0 this was 'SDomain'+ , PScale [ 'SDomainOpt' ('DSelection' \"brush\") ] ] . color [ MName \"Cluster\", MmType Nominal ] @@ -4115,7 +4159,7 @@ ] . position Y [ PName "plx" , PmType Quantitative- , PScale [ SDomain (DSelection "brush") ]+ , PScale [ SDomainOpt (DSelection "brush") ] ] . color [ MName "Cluster", MmType Nominal ] @@ -4236,42 +4280,34 @@ <<images/vl/loessexample.png>> -<https://vega.github.io/editor/#/url/vega-lite/N4KABGBEAuBOCGA7AzgMwPawLaQFxgG1hJUBLAG2gFNY8oAKAE3mgFcsA6AEQFEB9AJIBhAEoBlMAD4AvGAAMASjAAyMExbtu-YeLAAeWQBZFkAL4BdADTgozaPDqgIESK1jk6kABbRoAB2RcAHoghAB3DgBzUmgvVgAjVmQaAGN0RGoMjjSsIK50VkiAITcAayogrwA3Kkj4IKx4ZGpYSpq6oLt6utJ4AFp4foA2AEYhgZG5Pvt48ioR+A5EdD6vKnhGGg5oZCrIa2coDGwWRxtDyD94WGSzw4uAcUbIz0R2eJp98-vIEQBBQSiMSvd6fA73Fx+cgADxBWA+tHBEMgvEB4jhCK+EJcVD4UNh+Egb3hn2+EFM3wp5PBkGQfioKTuzm8VFIkR8dAATABWORIqBhUiMWJc3n8yDkeAAT0++AIZLATmxkEasFKnj86FIGSxyqoiDSjG1L3wSuxUDS5EwjhIpCo5EYniE5CSLX2UGgUvpr3QWG18A8ligc0i+sd+De5HIpn5yIJioVyLI9vDUCe8BeseVyBSAaoNoAXjR0HRUAHkjHEz9Pd7CQBHVhIaAxFikGqQKvUztQKVM80uZMOjUw3X9qA5vOF4ul8tUStjlw1-P1xsZFvN9vdqnY7eHef3M3VhAoY44OXdw-myCRWAFPzxXtyyDO12fKzdlxNOgESCwoOQXt3wXYN0CoZBkGHP8PygdJPHTF4tyrIDlVVdVTVpOB0HKAB1IURXwTl-2aW9yk8WZ4BSdV-yXTxyG1fN92RfVDWNPtlXjYhB1TX93RgL1lygBsm3XNt83-eBoVICCI1YKNGOVR9FVtFNPF7aj+M8IS13sDcxKgCSpLoSNoyrXdnDM8wbH3SAABIczWRpPB8fxAhCdpFmiWIEg4Uh0CCeyqEaIJ3L6OjqGCwwOAAK2QWCaUtdgUC5GkyxSKhoBtLinRdZowQ9DTCWWP1EADMx4vSMgTUVClTCAA Open this visualization in the Vega Editor>+<https://vega.github.io/editor/#/url/vega-lite/N4IgLgTghgdgzgMwPYQLYgFwG1QIJYA2YAphJiABQAmUYArqgHQAiAogPoCSAwgEoDKAAgB8AXkEAGAJSCAZIOq0GLDjwGCAPOIAs0kAF8AugBoQNMFEyg6EAuQAWYMAAc4GAPTvoAd0YBzPDB7OgAjOjhSAGMkGBJYxmjUd2YkOj8AIRsAa2J3ewA3Yj8od1QoOBIIPMLi93MS4rwoAFooFoA2AEZ21s6JZosQgmJOqEYYJGb7YigqUkYwOHyQU2Q0WisQZygICM2AcTK-chgGENIVkF4AQS4+fhOzi9NnAgAPR9RzslM2O4FPt9LsR2K8PhgQKcvhd9LDTHBnMRIptpng-I5MAAmACsElM3jwVCCWNxpgIUAAnhdsKAyhAsuRnEg8LFgTBolQWccMKBogQUJt8MQCFRyNwCOFKpdhn5iDBRRhTgQCPpTODcHhhQqQIcoMd4ZEoMNNgAvUhITAII0RVXgCmI8gARzosDAgVoeEKBlMFMFmpFjPelzghuNPJAZogFowVoINtMYHtxCdLti7rdXthqtAkFgiBQ6BpID8UbozhCvuwIHFkouJhA-OIcDggY+phi5F1xyMpjpDPDFSjOQA6oTiRhMfDIEgcuQhlBIgyE0nyAQWcnbXKOVzNuqQEKAxCu8HQ8nw5Ho7H43aHRDna7056Nz6-VrWyejWfQBfLdbiLbE1vEB7zTCwMw3WFDFtAASENpjKBwnFcDx3BqMYAiCUJGDwJB3Dg4gylQooWjXEhUO0RgACs4A7Uw+QYeAsVWBdiDAV9D2rCUKmeG8z0hJBUBZI0DH0IA Open this visualization in the Vega Editor> @ let simplify = transform . filter (FExpr \"(datum.DE_ICRS >= 0) & (datum.DE_ICRS <= 40)\") - rawEnc = encoding- . position X [ PName \"Gmag\"- , PmType Quantitative- , PScale [ SZero False ]- ]- . position Y [ PName \"plx\"- , PmType Quantitative- , PScale [ SZero False ]- ]+ baseEnc = encoding+ . position X [ PName \"Gmag\"+ , PmType Quantitative+ , PScale [ SZero False ]+ ]+ . position Y [ PName \"plx\"+ , PmType Quantitative+ , PScale [ SZero False ]+ ]++ rawEnc = baseEnc . color [ MName \"Cluster\"- , MmType Nominal , MLegend [] ] rawLayer = asSpec [ rawEnc [], mark Point [] ] trans = transform- . 'loess' \"plx\" \"Gmag\" [ 'LsAs' \"x\" \"y\"- , 'LsGroupBy' [ \"Cluster\" ] ]-- trendAx pos lbl = position pos [ PName lbl- , PmType Quantitative- , PAxis []- ]- trendEnc = encoding- . trendAx X \"x\"- . trendAx Y \"y\"+ . 'loess' \"plx\" \"Gmag\" [ 'LsGroupBy' [ \"Cluster\" ] ] trendLayer = asSpec [ trans []- , trendEnc []+ , baseEnc [] , mark Line [ MStroke \"black\" , MStrokeWidth 2 ]@@ -4306,36 +4342,28 @@ let simplify = transform . filter (FExpr "(datum.DE_ICRS >= 0) & (datum.DE_ICRS <= 40)") - rawEnc = encoding- . position X [ PName "Gmag"- , PmType Quantitative- , PScale [ SZero False ]- ]- . position Y [ PName "plx"- , PmType Quantitative- , PScale [ SZero False ]- ]- . color [ MName "Cluster"- , MmType Nominal- , MLegend []- ]+ baseEnc = encoding+ . position X [ PName "Gmag"+ , PmType Quantitative+ , PScale [ SZero False ]+ ]+ . position Y [ PName "plx"+ , PmType Quantitative+ , PScale [ SZero False ]+ ] + rawEnc = baseEnc+ . color [ MName "Cluster"+ , MLegend []+ ]+ rawLayer = asSpec [ rawEnc [], mark Point [] ] trans = transform- . loess "plx" "Gmag" [ LsAs "x" "y"- , LsGroupBy [ "Cluster" ] ]-- trendAx pos lbl = position pos [ PName lbl- , PmType Quantitative- , PAxis []- ]- trendEnc = encoding- . trendAx X "x"- . trendAx Y "y"+ . loess "plx" "Gmag" [ LsGroupBy [ "Cluster" ] ] trendLayer = asSpec [ trans []- , trendEnc []+ , baseEnc [] , mark Line [ MStroke "black" , MStrokeWidth 2 ]@@ -4364,42 +4392,28 @@ <<images/vl/regressionexample.png>> -<https://vega.github.io/editor/#/url/vega-lite/N4KABGBEAuBOCGA7AzgMwPawLaQFxgG1hJUBLAG2gFNY8oAKAE3mgFcsA6AEQFEB9AJIBhAEoBlMAD4AvGAAMASjAAyMExbtu-YeLAAeWQBZFkAL4BdADTgoACyqkA5reh0AzHLnWIkZtHh0oBA+rLDkdJAu0AAOyLgA9PEIAO4cjqTQtqwARqzINADG6IjUJRxFWPFc6KyOAEKhANZU8bYAblSO8PFY8MjUsK0dXfF+3V2k8AC08NMAbACMczMLclP+2eRUC-AciOhT9vCMNBzQyG2Q3sEkmL2u+EHBPtHwsPmBNs8+AOK9jhFEOxsjQrl9vpARABBQSiMSA4Gg67fKDRcgADwRWBBtGREN4sPEWJxYJRPiofDRmPwkCB2NB4IgpnBzKZ10gyVIjEy7k87IAJMgCvZehEorEEvFhrt0pkchxSOh4kKRd1pVNyBkWm1DBwAFbIYqkqDkeAAT1B+AI4Kez0gvVgjQi0XQpBKxrtVEQRUYboBj0ZNyK5EwgRIpCo5EYESE5DyAyuUGgZuiVEB6Cwbvg4VMeLt1LAtrJ4cj0Zpf3gALzEKF2bTj0gAC8aOg6Khs-lc4G7cnUxEAI6sJDQDIsUgdSDdsBdslQM1hsil50YxOQWtbMPN2Ct-Dt8idyxJlP1qCD4ejkcT1nfa9sm2BmAIFAYbB0a2zosoyCObesaLZecrUgWN41BKwpx8Po30gTFD0gedwNnHxYE6FDkGQRVEGXWCIKgI1y3+SdZ1vYJEIhB0nQbfpt2aAB1LkeXwAAmODqPQZoIk2eACidODexPSBNUQNMZwhL0fT9T5Z0gYNQwbRcoxjON+iRI8+xpfZM0QbMzGrHwC2IBSyygWC1IEs8Sgvcc0zg+B0VIZA6CBchyFEr9AMLEtFJpec+OPAch0s-xLxsqA7IcpzWBckimRZGwyJk4oyH9QtmVMIA Open this visualization in the Vega Editor>+<https://vega.github.io/editor/#/url/vega-lite/N4IgLgTghgdgzgMwPYQLYgFwG1QIJYA2YAphJiABQAmUYArqgHQAiAogPoCSAwgEoDKAAgB8AXkEAGAJSCAZIOq0GLDjwGCAPOIAs0kAF8AugBoQAC2J4A5mbCYAzBImmaYKJlB0IBcrbAAHOAwAemDoAHdGKzwwMzoAIzo4UgBjJBgSDMY01GDmJDorACEvAGtiYLMAN2IrKGDUKDgSCEqauuDXerq8KABaKH6ANgBGIYGRiT63eIJiEahGGCQ+iygqUkYwOCqQU2Q0Wg8QfygIZOOAcUarchgGeNI9kF4AQS4+fjuHp9N-AgAHt9UI8yKY2B8BMDQc9iOx-kCMCB7iCnvp0aZwngqLEHE5TAASOApCyNXxgAJBULtRbRWIJRh4JDBYmk+o0voEGIVKraRgAKzg6WeBCgAE8nthQI0IKVyP4kHgMrCYGkqErbhhQGkCChjvhiAQqORuAQki0DKZEbg8IbjUjrlBbqZiVA5scAF6kJCYBBu5L6UxgMX+YjkACOdFgYBitDwNUtIDF+ttRvlgOervdWpAXogPowfoIAaDIbDSMj0djMYT6MDoEgsEQKHQUpAVnzdH88WT2BApvNTxMIAgtVHcDgTJg6aBpmFDpuBmHMrlOea+fKAHVsbiMAAmF2QJDlcizKApOWl0PkLkwMOBkDEVVIdUwTXapC6sg5g1ppED5o0StFM7XIR1nRALNy1APMCyLEtwDLCMowyat43vUxextUCkQRTMUjdaDc29X1-WIB9g2vCsUJjNwa3vdFDH0IA Open this visualization in the Vega Editor> @ let simplify = transform . filter (FExpr \"(datum.DE_ICRS >= 0) & (datum.DE_ICRS <= 40)\") - rawAx pos lbl = position pos [ PName lbl- , PmType Quantitative- , PScale [ SZero False ]- ]- cluster = color [ MName \"Cluster\"- , MmType Nominal- ]-- rawEnc = encoding- . rawAx X \"Gmag\"- . rawAx Y \"plx\"- . cluster+ axis pos lbl = position pos [ PName lbl+ , PmType Quantitative+ , PScale [ SZero False ]+ ]+ enc = encoding+ . axis X \"Gmag\"+ . axis Y \"plx\"+ . color [ MName \"Cluster\" ] - rawLayer = asSpec [ rawEnc [], mark Point [] ]+ rawLayer = asSpec [ enc [], mark Point [] ] trans = transform- . 'regression' \"plx\" \"Gmag\" [ 'RgAs' \"x\" \"y\"- , 'RgGroupBy' [ \"Cluster\" ] ]-- trendAx pos lbl = position pos [ PName lbl- , PmType Quantitative- , PAxis []- ]- trendEnc = encoding- . trendAx X \"x\"- . trendAx Y \"y\"- . cluster+ . 'regression' \"plx\" \"Gmag\" [ 'RgGroupBy' [ \"Cluster\" ] ] trendLayer = asSpec [ trans []- , trendEnc []+ , enc [] , mark Line [ MStroke \"black\" , MStrokeWidth 2 ]@@ -4424,36 +4438,22 @@ let simplify = transform . filter (FExpr "(datum.DE_ICRS >= 0) & (datum.DE_ICRS <= 40)") - rawAx pos lbl = position pos [ PName lbl- , PmType Quantitative- , PScale [ SZero False ]- ]- cluster = color [ MName "Cluster"- , MmType Nominal- ]-- rawEnc = encoding- . rawAx X "Gmag"- . rawAx Y "plx"- . cluster+ axis pos lbl = position pos [ PName lbl+ , PmType Quantitative+ , PScale [ SZero False ]+ ]+ enc = encoding+ . axis X "Gmag"+ . axis Y "plx"+ . color [ MName "Cluster" ] - rawLayer = asSpec [ rawEnc [], mark Point [] ]+ rawLayer = asSpec [ enc [], mark Point [] ] trans = transform- . regression "plx" "Gmag" [ RgAs "x" "y"- , RgGroupBy [ "Cluster" ] ]-- trendAx pos lbl = position pos [ PName lbl- , PmType Quantitative- , PAxis []- ]- trendEnc = encoding- . trendAx X "x"- . trendAx Y "y"- . cluster+ . regression "plx" "Gmag" [ RgGroupBy [ "Cluster" ] ] trendLayer = asSpec [ trans []- , trendEnc []+ , enc [] , mark Line [ MStroke "black" , MStrokeWidth 2 ]
src/Graphics/Vega/VegaLite.hs view
@@ -14,7 +14,7 @@ it has been updated to match later versions. This module allows users to create a Vega-Lite specification, targeting __version 4__ of the <https://vega.github.io/schema/vega-lite/v4.json JSON schema>.-Version 0.10 of @hvega@ supports version 4.13 of the Vega-Lite specification.+Version 0.11 of @hvega@ supports version 4.15 of the Vega-Lite specification. Although this is based on the Elm module, there are differences, such as using type constructors rather than functions for many properties -@@ -65,7 +65,7 @@ enc = 'VL.encoding' . 'VL.position' 'VL.X' [ 'VL.PName' \"Horsepower\", 'VL.PmType' 'VL.Quantitative' ] . 'VL.position' 'VL.Y' [ 'VL.PName' \"Miles_per_Gallon\", 'VL.PmType' 'VL.Quantitative', 'VL.PTitle' \"Miles per Gallon\" ]- . 'VL.color' [ 'VL.MName' \"Origin\", 'VL.MmType' 'VL.Nominal' ]+ . 'VL.color' [ 'VL.MName' \"Origin\" ] bkg = 'VL.background' \"rgba(0, 0, 0, 0.05)\" @@ -92,7 +92,7 @@ The visualization can be viewed in the Vega Editor, which lets you interact with the plot and modify its contents, as shown for-<https://vega.github.io/editor/#/url/vega-lite/N4IgtghgTg1iBcoAuB7FAbJBLADg0AxigHZICmpCIFRAJlsQOYgC+ANCEgJ45lUFYoBdH3YhaEJBHwgArlHRUAFkiQ4AzvAD0WgG5lGEAHSMsSJbIBGRrCj0GIAWglT1ZJOq0uIWgtHVGAFbqJKwcACTqBEpkkMqqGtr2hiZmFta2WlExkMlO6GZkegAsQSHEIBw0KPRMMkToKFAyAGZYZOi0VADyUFimFRzcvFTEKGAMEIpiAB6t7Z1UABJNbjgoAO5kzUM8fPAgAI6yEKRmklj6YSBc8x1dBwCyWCLqAPq8UG8A4lONg5wzCIqM9XgACT5g37of6VTh7KjHU7YKTYK4sMSWCAEGCMKAoWTEB4gKCMLEACgADGxqbSjJSAKwASlYQA this example>.+<https://vega.github.io/editor/#/url/vega-lite/N4IgtghgTg1iBcoAuB7FAbJBLADg0AxigHZICmpCIFRAJlsQOYgC+ANCEgJ45lUFYoBdH3YhaEJBHwgArlHRUAFkiQ4AzvAD0WgG5lGEAHSMsSJbIBGRrCj0GIAWglT1ZJOq0uIWgtHVGAFbqJKwcACTqBEpkkMqqGtr2hiZmFta2WlExkMlO6GZkegAsQSHEIBw0KPRMMkToKFAyAGZYZOi0VADyUFimFWIAHq3tnVQAEk1uOCgA7mTNHNy8VACOshCkZpJY+mEgXKMdXfAgALJYIuoA+rxQNwDiEOiNFctmIlSX1wAE979nq9QsseHwzhsttgpNh9iwxJYIAQYIwoChZMRTiAoIxEQAKAAMbF+RJJxIJRgJAFYAJSsIA this example>. It can also be viewed as a PNG version: @@ -156,7 +156,7 @@ -- Define the properties used for the "position" channels. For this example -- it makes sense to define as functions since they are used several times. --- pos1Opts fld ttl = ['VL.PName' fld, 'VL.PmType' 'VL.Quantitative', 'VL.PAxis' ['VL.AxTitle' ttl]]+ pos1Opts fld ttl = ['VL.PName' fld, 'VL.PmType' 'VL.Quantitative', 'VL.PTitle' ttl] x1Opts = pos1Opts \"days\" \"Days since January 1, 2020\" y1Opts = pos1Opts \"magnitude\" \"Magnitude\" ++ ['VL.PSort' ['VL.Descending'], y1Range] y1Range = 'VL.PScale' ['VL.SDomain' ('VL.DNumbers' [-1, 3])]@@ -164,7 +164,7 @@ -- The filter name is used as a facet, but also to define the -- color and shape of the points. --- filtOpts = ['VL.MName' \"filterName\", 'VL.MmType' 'VL.Nominal']+ filtOpts = ['VL.MName' \"filterName\"] filtEnc = 'VL.color' ('VL.MLegend' ['VL.LTitle' \"Filter\", 'VL.LTitleFontSize' 16, 'VL.LLabelFontSize' 14] : filtOpts) . 'VL.shape' filtOpts @@ -199,8 +199,8 @@ -- What is plotted in the "detail" plot? -- selName = \"brush\"- pos2Opts fld = [ 'VL.PName' fld, 'VL.PmType' 'VL.Quantitative', 'VL.PAxis' ['VL.AxNoTitle']- , 'VL.PScale' ['VL.SDomain' ('VL.DSelectionField' selName fld)] ]+ pos2Opts fld = [ 'VL.PName' fld, 'VL.PmType' 'VL.Quantitative', 'VL.PNoTitle'+ , 'VL.PScale' ['VL.SDomainOpt' ('VL.DSelectionField' selName fld)] ] x2Opts = pos2Opts \"days\" y2Opts = pos2Opts \"magnitude\" ++ ['VL.PSort' ['VL.Descending']] @@ -231,7 +231,6 @@ -- details = 'VL.asSpec' [ 'VL.columns' 1 , 'VL.facetFlow' [ 'VL.FName' \"filterName\"- , 'VL.FmType' 'VL.Nominal' , 'VL.FHeader' headerOpts ] , 'VL.spacing' 10@@ -266,7 +265,7 @@ However this is missing the interactive elements of the visualization, primarily selection and zooming in the top plot changes the axis ranges of the bottom two plots. This interactivity requires a Vega-Lite viewer such as-<https://vega.github.io/editor/#/url/vega-lite/N4KABGBEAuBOCGA7AzgMwPawLaQFxgG1wIxhJUBLAG2gFNY8oATeaAVywDpKb6A5eFloEADAF0wAXmlgA5ADVZkAL4AaYhDI86DfJBbsuWeAHNEFdk1pgAPGAAsK9SVKR4yRvvgBPD6qgAxvBUAWxUrLSeBhycAFZMYAC0YABM9gCsAByZ9gCcnCIqxGLOgeiIlCaMoC5uAB4UHvg1LlDQFlS0AGLl0ADqtBQmABbQnoiYxlSQpbXhAEa0VD2I0ADKFABekfgAjPazJDAd3b0b24y7AGwaYMrEasRe0PDVt5BssNN6o9AADshcAB6IEIADunBMFmGbHmbGQ9ACvVoq04SKwQIAIug2CYAEKfADWtCBwwAbrQTPAgcZkDpSRSqUCDNTFnQqCZaPDaIkUiI+YkRABmRK7fKxZDlSAPUqQMlIxBBMb4IguFq1YaDEbKsC7dIiQ4QSDGWCE6qQdB-eABCzeRgiTjpfwwbx-HZQP7oCirGZQHidJiMVDBBGPVpQMEUJjQYaMK4iA23I0IzoBdpS5pJo7zWDw2OZ8O1b0Wc11RgEXl8-y7BMlKB2lWCx3+FKOsRhwtGlFIpjekxNQiQMvOu0lLO1aCu92Qb06MnBaWd+7hju1bvoXuIKoFwuQJFUTBvTtGyhLQN6bT8QSRQ2tF1u8boLDehe3uaUlHn0jju8LJYrdYtndfY3zvdpoE6TwumoHQZh-CcTgA85gJuY87h-Vc72QYZ4AfZpyAoM9PEvWABCEX172nCZn0QBdMNqMsd07AiiL0FhfDgtDKM8ABHNgkHA1gKApTjj3qRpzXAyC9ExHxkDAZBvQCawACkkH42BvF1Ft+UKZdC3oo4G2-LjTyoL9jVMcxLBveCoGQIJpNcJgn3gb1y1FfwhXbUDk0wHV9FoBzPz7UTmMnPCoD4gSLCEkTfKgeAGgHMgpOnABZKyLDYKwiiXLN9IgTD1SOZA3QCI9d01IZRkufVQMs01zUta1bXtZs2inTxPVnCj-VoL9gyoUMGsjaN8zAeNE2Y9dN23EyxP3Q8mLEsyLJIsjbLQo0Iqop8X2mBKjU6TlEC-EquL-ZYziAy4DjshCIOnaDeAYI6jjSpDbr2VDtsKgyEsgbDcPdLRCPM4iYKvcjnV2x8aLowHGIW0zwYs9i-Ae+zHNB-RXPc-C1qiOSKJTWg0woDMoBzPMVEM8NuL0aLVli9p4qx8SUuOJ7GEQMIqH+ldAeMi7dyJvRjDMbLcveoGcfNFzjAJ1xxagSXrJym97KWcn00QTwaewunZclWAAqsYKztC2W4aZ-iWZeNmtu2znJJOXn+cF1ovaKgrbz3dAqA4FBLn94NlJ1UWTzRyHXs2sK701eArF0FHdyugBBRVhmWqBPwThmroAUTqP5U8gWQXp0fBZDAABqMBoi4K6C9-eBFioAAFZO5sYXl7su9v-xui4fsBtKPaoKhAczqghn1vRYBqsYMIa22oGog7F29-2ytardLhEW59LHI0ABIHM1YxPF+AFgSBRl4EhaFYU4SmgUv2hjAfyl4ESOe6AP3sHESU+tZQTxWjAWgdQAp4loOyD83JZDyXVtLawQh3CfC-iiaAyB-D7nCHQBI8wtIZwzvINYAB5BO5AR7AUyDKJ4FsAhLz+HrTwAAJdAYIwA4XknA9knIkHyRzMvRAQV5LziXgNfw8x3ADTAOURurB4BgAIREYhpDyFULAAAClvoCEEYJjGcHgPAMkkpOCYBMECAAlJwMAABNHECkc5hASCGdAYADzoEJGAVgvDoD-EMUCaAkYgn0DRE+IEbIljzHQNAfxZ1AnBPvlCGMr90SkgoH8P4xIYnwLiQkhxABJRJYJ3D+KnmAGM1gECckUYgBS6AbTBDAEIXsqiAm1IUi8M2ijUCpF0pwaUyggA the Vega Editor>.+<https://vega.github.io/editor/#/url/vega-lite/N4IgLgTghgdgzgMwPYQLYgFwG1QIJYA2YAphJiACZRgCuqAdPkaQHJSrFYAMAugAQBeIXwDkANREgAvgBpchEmQyVqdeqigBzGHloVifADx8ALNLkgocclQCe1mSADGUAk5oFqxG6oYArCj4AWj4AJhMAVgAOKJMATnouaR5HJyQYfE1MUCgADzxrDFAwXQJiADF0sAB1YjxNAAswchgUDQIQR08AI2ICSpgwAGU8AC9vDABGE0cSsDKB4bGJyYA2KVkVMChskBoIDuUmsAAHOAwAegvoAHd6TV0Gmm6aOFI0weJB+jTUC4ARJA0TQAIX2AGtiBcGgA3YiaKAXDRwRTQuEIi5UbYXXokAiaYivYhBUJcUlBLgAZiCkwSfjg6XMIBhHxczWwoAadUa7MmES4jg0EHBuyQJygTl0tkwXHoEVmthOExAJyQeEGnRATDKFEwCFcb02NzwFDADUwqy4ApAbzKThKjKKIG6EFe5qd6t0u1ymCwJNJMkmVpSIGl2ApcpkoTlPE2XzSFHVmkKWBAPsc0pDYEVyvVihhrmkcZgCaTuzSBBQu3wfV1yiYijYHE1ZQJMDroB6fUWI3GmGms1KyvKClImrmCyqvZW602cAaUCV1bwtfIDdY7G8mx9TprBDrKns46H5H+UHsfDg6qcBgAUrAaFAILY+JMZGEyUkFUvlABHR+DLo1B4HCTJhvIq7KBo2i6DQ+ianALhlLsFBIBo6q+jSMiUrGjgMhA7KUMQiFfImMBZIO8zKgAsloOh6N437Kv+sBzMBoEbLIoBwEqTi7Fy9RNP2-KCk+IpOmKEpSjKkbgDm5CqnmmrasQdb6gQhqOMaprupa1rxkgZFZE6FZVruK77muo4QE2jEgK2pG7F2-RTss-YzOAJ7KCOzBkJRk6DNO-aznhC4-hBln1tZtlMjuEUHnYDg2khEygKh6EwMukGHkltrEPaeCOs6rrzkW-kTDAHgEEx5AsYB2wlBxGZZZFIDQfRcF2YhripZQaFQBh5nZe1sHwXhfT5Q6mXKC6bplTaKCEfoJHtmW5WYJVBDVXJP4gHVbGNVuGypEgBB0PA-aOPqN7svFVm+TFjhclA+hKJ2UC9AQACCJYNGZICOV0H19AAorkJxKCAIg+YoGCiHwADUfBYmozktsDBAAAovUZmAkh5zk9m5UyrOtGCbdtzlfQQ9TTSAECCc0x02uKkrkf2XBSCGAAkiFcho5DHGclwXOiUD3I8zz0IVFx88QGii-CUBBDTJCiyY9D0oyZPFMQuSESCxB4vChJvCIcB8CNDGW8QVj7PLXxgHA74Vp4JCBN0L5fV9YhDAA8sprl9lMUSbMtTgMycU3kAAEkgNx8AuFuG3iBJEubfAuozMDERbBYM6p77dFYql8OkyPUFAfCu14Htez7-t8AAFEL5xXDcHf0FAUAwgy9AoJoFwAJT0HwACaQKXn9HiBAaSB8JWSDgnw1CJ2ApxtxcYDGuvpA-GhOJG303RIGAK-tmvG8iw8ZpS780J4CcJyQofeIn2Ao8AJJnzcVgr1tfAzQGGgASMuMBLxIElK4G2iYq6ryAZebYBEy4IA-KSeg0ggA the Vega Editor>. -} @@ -664,6 +663,7 @@ , VL.categoricalDomainMap , VL.domainRangeMap , VL.ScaleDomain(..)+ , VL.DomainLimits(..) , VL.ScaleRange(..) , VL.ScaleNice(..) , VL.NTimeUnit(..)@@ -857,6 +857,10 @@ -- -- $update + -- ** Version 0.11+ --+ -- $update01100+ -- ** Version 0.10 -- -- $update01000@@ -1263,6 +1267,51 @@ -- The following section describes how to update code that used -- an older version of @hvega@. +-- $update01100+-- The @0.11.0.0@ release updates @hvega@ to support version 4.15 of+-- the Vega-Lite schema.+--+-- Note that @hvega@ does __not__ provide any information to help users+-- take advantage of the (new to 4.14) ability to+-- omit the type of a field when+-- [it can be inferred](https://vega.github.io/vega-lite/docs/type.html).+-- As the type is currently optional in @hvega@ users can just+-- not give a type. The example [IHaskell notebooks](https://github.com/DougBurke/hvega/tree/master/notebooks)+-- have been updated to show off the optional support.+--+-- Similarly, Vega-Lite 4.14 allows you to share the type, scale, axis,+-- and legend in a shared encoding. There is no explicit support added in+-- @0.11.0.0@ because @hvega@ already allowed you to create the specification.+--+-- __New constructors__+--+-- The 'VL.OrderChannel' type has gained 'VL.OBand', 'VL.OTitle'/'VL.ONoTitle',+-- and conditional-predicate support with 'VL.ODataCondition',+-- 'VL.OSelectionCondition', and 'VL.ONumber' constructors.+--+-- The 'VL.MarkChannel' type has gained the 'VL.MNullValue' constructor.+--+-- +-- The 'VL.ScaleRange' type has gained 'VL.RField', 'VL.RMax', and 'VL.RMin'+-- constructors.+--+-- __Breaking Changes__+--+-- Domain settings in 'VL.ScaleProperty' and associated types have been+-- changed to better match the Vega-Lite schema: 'VL.SDomain' now takes+-- a new type ('VL.DomainLimits') which actually contains many of the+-- orignal symbols (so hopefully will require no changes), and a new+-- constructor has been added ('VL.SDomainOpt') which takes the+-- 'VL.ScaleDomain' type, which has seen new constructors - 'VL.DMax',+-- 'VL.DMaxTime', 'VL.DMid', 'VL.DMin', and 'VL.DMinTime' - as well as+-- some constructors moving to 'VL.DomainLimits'.+--+-- __Deprecated symbols__:+--+-- The 'VL.SDomainMid' constructor of 'VL.ScaleProperty' will be removed in a+-- future release as it has been replaced by the 'VL.DMid' constructor+-- in 'VL.ScaleDomain'. + -- $update01000 -- The @0.10.0.0@ release updates @hvega@ to support version 4.13 of -- the Vega-Lite schema.
src/Graphics/Vega/VegaLite/Core.hs view
@@ -275,9 +275,11 @@ ) import Graphics.Vega.VegaLite.Scale ( ScaleDomain(..)+ , DomainLimits(..) , ScaleRange(..) , ScaleNice- , scaleDomainSpec+ , scaleDomainProperty+ , domainLimitsSpec , scaleNiceSpec ) import Graphics.Vega.VegaLite.Specification@@ -297,7 +299,7 @@ import Graphics.Vega.VegaLite.Time ( DateTime , TimeUnit- , dateTimeProperty+ , dateTimeSpec , timeUnitSpec ) import Graphics.Vega.VegaLite.Transform@@ -555,6 +557,10 @@ -- ^ Literal string value when encoding with a mark property channel. | MBoolean Bool -- ^ Boolean value when encoding with a mark property channel.+ | MNullValue+ -- ^ A null value.+ --+ -- @since 0.11.0.0 | MSymbol Symbol -- ^ A symbol literal. This can be useful when making a symbol dependent on some data or -- selection condition (e.g. 'MDataCondition' or 'MSelectionCondition').@@ -593,6 +599,7 @@ markChannelProperty (MString s) = ["value" .= s] markChannelProperty (MBoolean b) = ["value" .= b] markChannelProperty (MSymbol s) = ["value" .= symbolLabel s]+markChannelProperty MNullValue = ["value" .= A.Null] markChannelProperty (MTitle s) = ["title" .= splitOnNewline s] markChannelProperty MNoTitle = ["title" .= A.Null] @@ -755,12 +762,21 @@ -- The default is @1@. -- -- @since 0.4.0.0- | SDomain ScaleDomain- -- ^ Custom scaling domain.+ | SDomain DomainLimits+ -- ^ Custom scaling domain. See also 'SDomainOpt'.+ --+ -- In verson @0.11.0.0@ some functionality was moved to 'SDomainOpt'. | SDomainMid Double -- ^ Set the mid-point of a continuous diverging domain. --+ -- This is deprecated as of 0.11.0.0 and @'SDomainOpt' ('DMid' x)@ should be used+ -- instead.+ -- -- @since 0.6.0.0+ | SDomainOpt ScaleDomain+ -- ^ Custom scaling domain. See also 'SDomain'.+ --+ -- @since 0.11.0.0 | SExponent Double -- ^ The exponent to use for power scaling ('Graphics.Vega.VegaLite.ScPow'). --@@ -814,14 +830,18 @@ scaleProperty (SBins xs) = "bins" .= xs scaleProperty (SClamp b) = "clamp" .= b scaleProperty (SConstant x) = "constant" .= x-scaleProperty (SDomain sdType) = "domain" .= scaleDomainSpec sdType+scaleProperty (SDomain dl) = "domain" .= domainLimitsSpec dl scaleProperty (SDomainMid x) = "domainMid" .= x+scaleProperty (SDomainOpt sd) = scaleDomainProperty sd scaleProperty (SExponent x) = "exponent" .= x scaleProperty (SInterpolate interp) = "interpolate" .= cInterpolateSpec interp scaleProperty (SNice ni) = "nice" .= scaleNiceSpec ni scaleProperty (SPadding x) = "padding" .= x scaleProperty (SPaddingInner x) = "paddingInner" .= x scaleProperty (SPaddingOuter x) = "paddingOuter" .= x+scaleProperty (SRange (RField f)) = "range" .= object ["field" .= f]+scaleProperty (SRange (RMax x)) = "rangeMax" .= x+scaleProperty (SRange (RMin x)) = "rangeMin" .= x scaleProperty (SRange (RPair lo hi)) = "range" .= [lo, hi] scaleProperty (SRange (RHeight w)) = "range" .= [fromT "height", toJSON w] scaleProperty (SRange (RWidth h)) = "range" .= [toJSON h, fromT "width"]@@ -1713,7 +1733,7 @@ axisProperty (AxTitleY x) = "titleY" .= x axisProperty (AxTranslateOffset x) = "translate" .= x axisProperty (AxValues vals) = "values" .= dataValuesSpecs vals-axisProperty (AxDates dtss) = "values" .= map (object . map dateTimeProperty) dtss+axisProperty (AxDates dtss) = "values" .= map dateTimeSpec dtss axisProperty (AxZIndex z) = "zindex" .= z @@ -2037,14 +2057,14 @@ DateRange dMin dMax -> [process dMin, process dMax] process [] = A.Null- process dts = object (map dateTimeProperty dts)+ process dts = dateTimeSpec dts in [field_ field, "range" .= ans] filterProperty (FOneOf field vals) = let ans = case vals of Numbers xs -> map toJSON xs- DateTimes dts -> map (object . map dateTimeProperty) dts+ DateTimes dts -> map dateTimeSpec dts Strings ss -> map toJSON ss Booleans bs -> map toJSON bs @@ -2535,6 +2555,8 @@ -- | Properties of an ordering channel used for sorting data fields. +-- maps to OrderFieldDef+ data OrderChannel = OName FieldName -- ^ The name of the field used for encoding with an order channel.@@ -2542,30 +2564,83 @@ -- ^ Reference in an order channel to a field name generated by 'repeatFlow' -- or 'repeat'. The parameter identifies whether reference is being made to -- fields that are to be arranged in columns, in rows, or a with a flow layout.- | OmType Measurement- -- ^ The level of measurement when encoding with an order channel.- | OBin [BinProperty]- -- ^ Discretize numeric values into bins when encoding with an- -- order channel. | OAggregate Operation -- ^ Compute some aggregate summary statistics for a field to be encoded -- with an order channel.+ | OBand Double+ -- ^ For rect-based marks, define the mark size relative to the bandwidth of+ -- band scales, bins, or time units: a value of 1 uses the range and 0.5+ -- half the range. For other marks it defines the relative position in a+ -- band of a stacked, binned, time unit, or band scale: if 0 the marks+ -- will be positioned at the beginning of the band and 0.5 gives the+ -- middle of the band.+ --+ -- The argument must be in the range 0 to 1, inclusive, but there is no+ -- check on this.+ --+ -- @since 0.11.0.0+ | OBin [BinProperty]+ -- ^ Discretize numeric values into bins when encoding with an+ -- order channel.+ | OSort [SortProperty]+ -- ^ Sort order for field when encoding with an order channel. | OTimeUnit TimeUnit -- ^ Form of time unit aggregation of field values when encoding with -- an order channel.- | OSort [SortProperty]- -- ^ Sort order for field when encoding with an order channel.---orderChannelProperty :: OrderChannel -> LabelledSpec-orderChannelProperty (OName s) = field_ s-orderChannelProperty (ORepeat arr) = "field" .= object [repeat_ arr]-orderChannelProperty (OmType measure) = mtype_ measure-orderChannelProperty (OBin bps) = bin bps-orderChannelProperty (OAggregate op) = aggregate_ op-orderChannelProperty (OTimeUnit tu) = timeUnit_ tu-orderChannelProperty (OSort ops) = sort_ ops+ | OTitle T.Text+ -- ^ The title for the field.+ --+ -- Note that if both the field and axis, header, or legend titles are+ -- defined than the latter (axis, header, or legend) will be used.+ --+ -- @since 0.11.0.0+ | ONoTitle+ -- ^ Remove the title.+ --+ -- @since 0.11.0.0+ | OmType Measurement+ -- ^ The level of measurement when encoding with an order channel.+ | ODataCondition [(BooleanOp, [OrderChannel])] [OrderChannel]+ -- ^ Make an order channel conditional on one or more predicate expressions. The first+ -- parameter is a list of tuples each pairing an expression to evaluate with the encoding+ -- if that expression is @True@. The second is the encoding if none of the expressions+ -- evaluate as @True@.+ --+ -- @since 0.11.0.0+ | OSelectionCondition BooleanOp [OrderChannel] [OrderChannel]+ -- ^ Make an order channel conditional on interactive selection. The first parameter+ -- is a selection condition to evaluate; the second the encoding to apply if that+ -- selection is true; the third parameter is the encoding if the selection is false.+ --+ -- An example:+ --+ -- @'order' ['OSelectionCondition' ('SelectionName' "highlight")+ -- ['ONumber' 1] ['ONumber' 0]]+ -- @+ --+ -- @since 0.11.0.0+ | ONumber Double+ -- ^ Create a value with this number. For use with 'OSelectionCondition'+ -- and 'ODataCondition'.+ --+ -- @since 0.11.0.0 +orderChannelProperty :: OrderChannel -> [LabelledSpec]+orderChannelProperty (OAggregate op) = [aggregate_ op]+orderChannelProperty (OBand x) = ["band" .= x]+orderChannelProperty (OBin bps) = [bin bps]+orderChannelProperty (OName s) = [field_ s]+orderChannelProperty (ORepeat arr) = ["field" .= object [repeat_ arr]]+orderChannelProperty (OSort ops) = [sort_ ops]+orderChannelProperty (OTimeUnit tu) = [timeUnit_ tu]+orderChannelProperty (OTitle s) = ["title" .= s]+orderChannelProperty ONoTitle = ["title" .= A.Null]+orderChannelProperty (OmType measure) = [mtype_ measure]+orderChannelProperty (ODataCondition tests elseClause) =+ dataCond_ orderChannelProperty tests elseClause+orderChannelProperty (OSelectionCondition selName ifClause elseClause) =+ selCond_ orderChannelProperty selName ifClause elseClause+orderChannelProperty (ONumber n) = ["value" .= n] -- | Level of detail channel properties used for creating a grouped channel -- encoding.@@ -4661,19 +4736,27 @@ Encode an order channel. @-enc =- 'encoding'- . 'position' 'Graphics.Vega.VegaLite.X' [ 'PName' "miles", 'PmType' 'Graphics.Vega.VegaLite.Quantitative' ]- . 'position' 'Graphics.Vega.VegaLite.Y' [ 'PName' "gas", 'PmType' 'Graphics.Vega.VegaLite.Quantitative' ]- . 'order' [ 'OName' "year", 'OmType' 'Graphics.Vega.VegaLite.Temporal', 'OSort' ['Descending'] ]+'encoding'+ . 'position' 'Graphics.Vega.VegaLite.X' [ 'PName' "miles", 'PmType' 'Graphics.Vega.VegaLite.Quantitative' ]+ . 'position' 'Graphics.Vega.VegaLite.Y' [ 'PName' "gas", 'PmType' 'Graphics.Vega.VegaLite.Quantitative' ]+ . 'order' [ 'OName' "year", 'OmType' 'Graphics.Vega.VegaLite.Temporal', 'OSort' ['Descending'] ] @++<https://vega.github.io/vega-lite/docs/condition.html Conditional values>+can be set with 'OSelectionCondition', such as++@+'order' [ 'OSelectionCondition' ('SelectionName "highlight")+ ['ONumber' 1] ['ONumber' 0]+@ -}+ order :: [OrderChannel] -- ^ The order-encoding options. -> BuildEncodingSpecs order oDefs ols =- ES ("order", object (map orderChannelProperty oDefs)) : ols+ ES ("order", object (concatMap orderChannelProperty oDefs)) : ols {-|
src/Graphics/Vega/VegaLite/Data.hs view
@@ -24,13 +24,13 @@ import qualified Data.Aeson as A import qualified Data.Text as T -import Data.Aeson (object, toJSON)+import Data.Aeson (toJSON) import Graphics.Vega.VegaLite.Specification (VLSpec) import Graphics.Vega.VegaLite.Time ( DateTime- , dateTimeProperty+ , dateTimeSpec ) @@ -68,7 +68,7 @@ dataValueSpec :: DataValue -> VLSpec dataValueSpec (Boolean b) = toJSON b-dataValueSpec (DateTime dt) = object (map dateTimeProperty dt)+dataValueSpec (DateTime dt) = dateTimeSpec dt dataValueSpec (Number x) = toJSON x dataValueSpec (Str t) = toJSON t dataValueSpec NullValue = A.Null@@ -94,7 +94,7 @@ dataValuesSpecs :: DataValues -> [VLSpec] dataValuesSpecs (Booleans bs) = map toJSON bs-dataValuesSpecs (DateTimes dtss) = map (object . map dateTimeProperty) dtss+dataValuesSpecs (DateTimes dtss) = map dateTimeSpec dtss dataValuesSpecs (Numbers xs) = map toJSON xs dataValuesSpecs (Strings ss) = map toJSON ss
src/Graphics/Vega/VegaLite/Input.hs view
@@ -65,7 +65,7 @@ , VLSpec , LabelledSpec )-import Graphics.Vega.VegaLite.Time (dateTimeProperty)+import Graphics.Vega.VegaLite.Time (dateTimeSpec) {-|@@ -433,11 +433,10 @@ dataColumn colName dVals xs = let col = case dVals of Booleans cs -> map toJSON cs- DateTimes cs -> map dtToJSON cs+ DateTimes cs -> map dateTimeSpec cs Numbers cs -> map toJSON cs Strings cs -> map toJSON cs - dtToJSON = object . map dateTimeProperty x = map (colName,) col in x : xs
src/Graphics/Vega/VegaLite/Legend.hs view
@@ -73,7 +73,7 @@ import Graphics.Vega.VegaLite.Specification (VLSpec, LabelledSpec) import Graphics.Vega.VegaLite.Time ( DateTime- , dateTimeProperty+ , dateTimeSpec ) @@ -561,7 +561,7 @@ legendProperty (LValues vals) = let ls = case vals of LNumbers xs -> map toJSON xs- LDateTimes dts -> map (object . map dateTimeProperty) dts+ LDateTimes dts -> map dateTimeSpec dts LStrings ss -> map toJSON ss in "values" .= ls legendProperty (LeX x) = "legendX" .= x
src/Graphics/Vega/VegaLite/Scale.hs view
@@ -15,12 +15,14 @@ module Graphics.Vega.VegaLite.Scale ( ScaleDomain(..)+ , DomainLimits(..) , ScaleRange(..) , ScaleNice(..) , NTimeUnit(..) -- not for external export- , scaleDomainSpec+ , scaleDomainProperty+ , domainLimitsSpec , scaleNiceSpec ) where @@ -37,11 +39,12 @@ ) import Graphics.Vega.VegaLite.Specification ( VLSpec+ , LabelledSpec , SelectionLabel ) import Graphics.Vega.VegaLite.Time ( DateTime- , dateTimeProperty+ , dateTimeSpec ) @@ -49,15 +52,44 @@ Describes the scale domain (type of data in scale). For full details see the <https://vega.github.io/vega-lite/docs/scale.html#domain Vega-Lite documentation>.++In @0.11.0.0@ the functionality has been split into 'ScaleDomain' and+'DomainLimits'. -} data ScaleDomain- = DNumbers [Double]- -- ^ Numeric values that define a scale domain.- | DStrings [T.Text]- -- ^ String values that define a scale domain.- | DDateTimes [[DateTime]]- -- ^ Date-time values that define a scale domain.+ = DMax Double+ -- ^ Sets the maximum value in the scale domain.+ -- It is only intended for scales with a continuous domain.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0+ | DMaxTime [DateTime]+ -- ^ 'DMax' for dates.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0+ | DMid Double+ -- ^ Sets the mid-point of a continuous diverging domain.+ --+ -- It replaces 'Graphics.Vega.VegaLite.SDomainMid'.+ --+ -- @since 0.11.0.0+ | DMin Double+ -- ^ Sets the minimum value in the scale domain.+ -- It is only intended for scales with a continuous domain.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0+ | DMinTime [DateTime]+ -- ^ 'DMin' for dates.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0 | DSelection SelectionLabel -- ^ Scale domain based on a named interactive selection. -- See also 'DSelectionField' and 'DSelectionChannel', which should@@ -77,38 +109,74 @@ -- is projected over multiple fields or encodings. -- -- @since 0.7.0.0- | DUnionWith ScaleDomain+ | DUnionWith DomainLimits -- ^ Combine the domain of the data with the provided domain. -- -- The following example will use a range of at least 0 to 100, -- but this will be increased if the data (either initially or -- via any updates to the Vege-Lite visualization) exceeds this: --- -- @'Graphics.Vega.VegaLite.PScale' ['Graphics.Vega.VegaLite.SDomain' (DUnionWith ('DNumbers' [0, 100]))]@- --- -- Note that 'DUnionWith' should not be nested, but this- -- is not enforced by @hvega@.+ -- @'Graphics.Vega.VegaLite.PScale' ['Graphics.Vega.VegaLite.SDomainOpt' (DUnionWith ('DNumbers' [0, 100]))]@ -- -- @since 0.6.0.0 | Unaggregated- -- ^ Indicate that a domain of aggregated data should be scaled to- -- the domain of the data prior to aggregation.+ -- ^ Indicate that a domain of aggregated data should be scaled to+ -- the domain of the data prior to aggregation. -scaleDomainSpec :: ScaleDomain -> VLSpec-scaleDomainSpec (DNumbers nums) = toJSON (map toJSON nums)-scaleDomainSpec (DDateTimes dts) = toJSON (map (object . map dateTimeProperty) dts)-scaleDomainSpec (DStrings cats) = toJSON (map toJSON cats)-scaleDomainSpec (DSelection selName) = object ["selection" .= selName]-scaleDomainSpec (DSelectionField selName field) = object [ "selection" .= selName- , "field" .= field ]-scaleDomainSpec (DSelectionChannel selName ch) = object [ "selection" .= selName- , "encoding" .= channelLabel ch ]-scaleDomainSpec (DUnionWith sd) = object ["unionWith" .= scaleDomainSpec sd]-scaleDomainSpec Unaggregated = "unaggregated" +-- For now we do not include Unaggregated in DomainLimits as the+-- documentaiton suggests we should ubt the schema does not: see+-- https://github.com/vega/vega-lite/issues/7022+-- {-| +Represent the range of the domain, which is used by 'VL.SDomain'+and 'DUnionWith'.++Prior to @0.11.0.0@ this was part of 'ScaleDomain'.++@since 0.11.0.0+-}+data DomainLimits+ = DNumbers [Double]+ -- ^ Numeric values that define a scale domain.+ --+ -- It is expected that this contains two values (minimum and+ -- maximum), but more can be given for+ -- [piecewise quantitative scales](https://vega.github.io/vega-lite/docs/scale.html#piecewise).+ | DStrings [T.Text]+ -- ^ String values that define a scale domain+ | DDateTimes [[DateTime]]+ -- ^ Date-time values that define a scale domain.+++scaleDomainProperty :: ScaleDomain -> LabelledSpec++scaleDomainProperty (DMax x) = "domainMax" .= x+scaleDomainProperty (DMaxTime dts) = "domainMax" .= dateTimeSpec dts+scaleDomainProperty (DMid x) = "domainMid" .= x+scaleDomainProperty (DMin x) = "domainMin" .= x+scaleDomainProperty (DMinTime dts) = "domainMin" .= dateTimeSpec dts+++scaleDomainProperty (DSelection selName) = "domain" .= object ["selection" .= selName]+scaleDomainProperty (DSelectionField selName field) = "domain" .= object [ "selection" .= selName+ , "field" .= field ]+scaleDomainProperty (DSelectionChannel selName ch) = "domain" .= object [ "selection" .= selName+ , "encoding" .= channelLabel ch ]+scaleDomainProperty (DUnionWith sd) = "domain" .= object ["unionWith" .= domainLimitsSpec sd]+scaleDomainProperty Unaggregated = "domain" .= fromT "unaggregated"+++domainLimitsSpec :: DomainLimits -> VLSpec+domainLimitsSpec (DNumbers nums) = toJSON (map toJSON nums)+domainLimitsSpec (DDateTimes dts) = toJSON (map dateTimeSpec dts)+domainLimitsSpec (DStrings cats) = toJSON (map toJSON cats)+++{-|+ Describes the way a scale can be rounded to \"nice\" numbers. For full details see the <https://vega.github.io/vega-lite/docs/scale.html#continuous Vega-Lite documentation>. @@ -188,7 +256,32 @@ -} data ScaleRange- = RPair Double Double+ = RField FieldName+ -- ^ For [discrete](https://vega.github.io/vega-lite/docs/scale.html#discrete)+ -- and [discretizing](https://vega.github.io/vega-lite/docs/scale.html#discretizing)+ -- scales, the name if the field to use.+ --+ -- For example. if the field \"color\" contains CSS color names, we can say+ -- @RField \"color\"@.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0+ | RMax Double+ -- ^ Sets the maximum value in the scale range.+ -- It is only intended for scales with a continuous range.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0+ | RMin Double+ -- ^ Sets the minimum value in the scale range.+ -- It is only intended for scales with a continuous range.+ --+ -- It is supported in Vega-Lite 4.14 and later.+ --+ -- @since 0.11.0.0+ | RPair Double Double -- ^ The minimum and maximum values. -- -- @since 0.9.0.0
src/Graphics/Vega/VegaLite/Time.hs view
@@ -22,7 +22,7 @@ , BaseTimeUnit(..) -- not for external export- , dateTimeProperty+ , dateTimeSpec , timeUnitSpec ) where@@ -378,6 +378,10 @@ dateTimeProperty (DTMinutes m) = "minutes" .= m dateTimeProperty (DTSeconds s) = "seconds" .= s dateTimeProperty (DTMilliseconds ms) = "milliseconds" .= ms+++dateTimeSpec :: [DateTime] -> VLSpec+dateTimeSpec = object . map dateTimeProperty dayLabel :: DayName -> T.Text
tests/CompositeTests.hs view
@@ -174,13 +174,13 @@ errorband2No = eBand "stdev" False +barley :: Data+barley = dataFromUrl "https://vega.github.io/vega-lite/data/barley.json" []++ eBar :: MarkErrorExtent -> VegaLite eBar ext =- let- barley =- dataFromUrl "https://vega.github.io/vega-lite/data/barley.json" []-- enc =+ let enc = encoding . position X [ PName "yield", PmType Quantitative , PScale [ SZero False ] ]@@ -235,7 +235,7 @@ in toVegaLite [ des- , dataFromUrl "https://vega.github.io/vega-lite/data/barley.json" []+ , barley , layer [ specErrorBars, specPoints ] ]
tests/ConditionalTests.hs view
@@ -25,6 +25,7 @@ , ("selectionCondition5", selectionCondition5) , ("bindScales1", bindScales1) , ("bindScales2", bindScales2)+ , ("selectionHeatMap", selectionHeatMap) ] @@ -325,3 +326,51 @@ in toVegaLite [ width 300, height 300, carData, sel [], mark Circle [], encHorses [] ]+++-- https://github.com/vega/vega-lite/blob/master/examples/specs/selection_heatmap.vl.json+--+selectionHeatMap :: VegaLite+selectionHeatMap =+ let dvals = dataFromColumns []+ . dataColumn "count" (Numbers [13, 0, 0, 0, 10, 6, 0, 0, 9])+ . dataColumn "actual" (Strings ["A", "A", "A", "B", "B", "B", "C", "C", "C"])+ . dataColumn "predicted" (Strings ["A", "B", "C", "A", "B", "C", "A", "B", "C"])++ enc = encoding+ . position X [PName "predicted", PmType Nominal]+ . position Y [PName "actual", PmType Nominal]+ . fill [MName "count", MmType Quantitative]+ . stroke [ MDataCondition+ [(And+ (Selection "highlight")+ (Expr "length(data(\"highlight_store\"))")+ , [MString "black"])]+ [MNullValue]+ ]+ . opacity [ MSelectionCondition+ (SelectionName "highlight")+ [MNumber 1]+ [MNumber 0.5]+ ]+ . order [ OSelectionCondition+ (SelectionName "highlight")+ [ONumber 1]+ [ONumber 0]+ ]++ sel = selection+ . select "highlight" Single []++ conf = configure+ . configuration (ScaleStyle [SCBandPaddingInner 0, SCBandPaddingOuter 0])+ . configuration (ViewStyle [ViewStep 40])+ . configuration (RangeStyle [RRamp "yellowgreenblue"])+ . configuration (Axis [Domain False])++ in toVegaLite [ dvals []+ , sel []+ , enc []+ , mark Rect [MStrokeWidth 2]+ , conf []+ ]
tests/DataTests.hs view
@@ -694,7 +694,7 @@ domain1, domain2, domain3 :: VegaLite domain1 = domain [] domain2 = domain [SDomain (DNumbers [90, 100])]-domain3 = domain [SDomain (DUnionWith (DNumbers [90, 100]))]+domain3 = domain [SDomainOpt (DUnionWith (DNumbers [90, 100]))] {-
tests/EncodingTests.hs view
@@ -13,6 +13,7 @@ testSpecs :: [(String, VegaLite)] testSpecs = [ ("strokedashgroup", strokeDashGroup) , ("strokedashline", strokeDashLine)+ , ("nullencoding", nullEncoding) ] @@ -41,3 +42,26 @@ . strokeDash [ MName "predicted", MmType Nominal ] $ [] ]++-- See https://github.com/vega/vega-lite/issues/6762+--+-- Note: a "null" encoding here is with no arguments, which creates {}.+-- We don't support creating null instead of {}.+--+nullEncoding :: VegaLite+nullEncoding =+ let dvals = dataFromColumns []+ . dataColumn "a" (Strings ["A", "B", "D", "E", "E", "G", "H", "I"])+ . dataColumn "b" (Numbers [28, 55, 91, 81, 81, 19, 87, 52])++ lyr1 = [mark Bar []]+ lyr2 = [mark Rule [], encoding (position X [] [])]+ + in toVegaLite [ description "Can we null the encoding"+ , dvals []+ , encoding+ . position X [PName "a", PmType Nominal, PAxis [AxLabelAngle 0]]+ . position Y [PName "b", PmType Quantitative]+ $ []+ , layer (map asSpec [lyr1, lyr2])+ ]
tests/Gallery/Bar.hs view
@@ -21,6 +21,8 @@ , ("bar4", bar4) , ("bar5", bar5) , ("bar6", bar6)+ , ("bar6order", bar6order)+ , ("bar6sort", bar6sort) , ("bar7", bar7) , ("bar8", bar8) , ("bar9", bar9)@@ -208,25 +210,58 @@ ] --- bar9 in GalleryBar.elm+barley :: Data+barley = dataFromUrl "https://vega.github.io/vega-lite/data/barley.json" []+++barleyEnc :: [EncodingSpec] -> PropertySpec+barleyEnc = encoding+ . position X [ PName "yield", PmType Quantitative, PAggregate Sum ]+ . position Y [ PName "variety", PmType Nominal ]+ . color [ MName "site", MmType Nominal ]+++-- bar9 in GalleryBar.elm, also first version of+-- https://vega.github.io/vega-lite/docs/stack.html#sorting-stack-order bar6 :: VegaLite bar6 =- let- des =- description "Barley crop yields as a horizontal stacked bar chart"+ let des = description "Barley crop yields as a horizontal stacked bar chart" - enc =- encoding- . position X [ PName "yield", PmType Quantitative, PAggregate Sum ]- . position Y [ PName "variety", PmType Nominal ]- . color [ MName "site", MmType Nominal ]- in- toVegaLite- [ des- , dataFromUrl "https://vega.github.io/vega-lite/data/barley.json" []- , mark Bar []- , enc []- ]+ in toVegaLite [ des+ , barley+ , mark Bar []+ , barleyEnc []+ ]+++-- tweaks to bar6 from https://vega.github.io/vega-lite/docs/stack.html#sorting-stack-order+--+bar6order :: VegaLite+bar6order =+ let enc = barleyEnc+ . order [ OName "yield", OmType Quantitative, OAggregate Sum ]++ in toVegaLite [ barley+ , mark Bar []+ , enc []+ ]+++-- tweaks to bar6 from https://vega.github.io/vega-lite/docs/stack.html#sorting-stack-order+--+bar6sort :: VegaLite+bar6sort =+ let enc = barleyEnc+ . order [ OName "siteOrder" ]++ trans = transform+ . calculateAs "if(datum.site === 'University Farm', 0, if(datum.site === 'Grand Rapids', 1, 2))" "siteOrder"++ in toVegaLite [ barley+ , trans []+ , mark Bar []+ , enc []+ ] -- bar10 in GalleryBar.elm
tests/Gallery/Facet.hs view
@@ -8,10 +8,13 @@ import Graphics.Vega.VegaLite --- import qualified Data.Text as T+import qualified Data.Text as T import Prelude hiding (filter, lookup, repeat) +import Data.Aeson (Value, (.=), object, toJSON)++ testSpecs :: [(String, VegaLite)] testSpecs = [ ("facet1", facet1) , ("facet2", facet2)@@ -22,6 +25,7 @@ , ("facet7", facet7) , ("trellisareaseattle", trellisAreaSeattle) , ("facetgridbar", facetGridBar)+ , ("facet_bullet", facetBullet) ] @@ -326,4 +330,70 @@ , spacing 5 , mark Bar [] , enc []+ ]+++bullets :: Value+bullets =+ let item :: T.Text -> T.Text -> [Double] -> [Double] -> [Double] -> Value+ item ttl subtitle ranges measures markers =+ object [ "title" .= ttl+ , "subtitle" .= subtitle+ , "ranges" .= ranges+ , "measures" .= measures+ , "markers" .= markers+ ]++ in toJSON [ item "Revenue" "US$, in thousands" [150,225,300] [220,270] [250]+ , item "Profit" "%" [20,25,30] [21,23] [26]+ , item "Order Size" "US$, average" [350,500,600] [100,320] [550]+ , item "New Customers" "count" [1400,2000,2500] [1000,1650] [2100]+ , item "Satisfaction" "out of 5" [3.5,4.25,5] [3.2,4.7] [4.4]+ ]+++-- https://vega.github.io/vega-lite/examples/facet_bullet.html+facetBullet :: VegaLite+facetBullet =+ let facetOpts = facet [ RowBy [ FName "title"+ , FmType Ordinal+ , FHeader [ HLabelAngle 0+ , HNoTitle ]+ ]+ ]++ plot = asSpec [ encoding+ (position X [ PmType Quantitative+ , PScale [SNice (IsNice False)]+ , PNoTitle+ ] [])+ , layer (map asSpec plots)+ ]++ encX fld = encoding (position X [PName fld] [])++ plots = [ [ mark Bar [MColor "#eee"]+ , encX "ranges[2]" ]+ , [ mark Bar [MColor "#ddd"]+ , encX "ranges[1]" ]+ , [ mark Bar [MColor "#ccc"]+ , encX "ranges[0]" ]+ , [ mark Bar [MColor "lightsteelblue", MSize 10]+ , encX "measures[1]" ]+ , [ mark Bar [MColor "steelblue", MSize 10]+ , encX "measures[0]" ]+ , [ mark Tick [MColor "black"]+ , encX "markers[0]" ]+ ]++ res = resolve . resolution (RScale [(ChX, Independent)])++ cfg = configure . configuration (TickStyle [MThickness 2])++ in toVegaLite [ dataFromJson bullets []+ , facetOpts+ , spacing 10+ , specification plot+ , res []+ , cfg [] ]
tests/Gallery/Geo.hs view
@@ -280,7 +280,7 @@ encoding . position Longitude [ PName "longitude", PmType Quantitative ] . position Latitude [ PName "latitude", PmType Quantitative ]- . order [ OName "order", OmType Ordinal ]+ . order [ OName "order" ] flightsSpec = asSpec
tests/Gallery/Line.hs view
@@ -134,7 +134,7 @@ encoding . position X [ PName "miles", PmType Quantitative, PScale [ SZero False ] ] . position Y [ PName "gas", PmType Quantitative, PScale [ SZero False ] ]- . order [ OName "year", OmType Temporal ]+ . order [ OName "year" ] in toVegaLite [ des
tests/Gallery/Multi.hs view
@@ -37,7 +37,7 @@ . position X [ PName "date" , PmType Temporal- , PScale [ SDomain (DSelection "myBrush") ]+ , PScale [ SDomainOpt (DSelection "myBrush") ] , PAxis [ AxNoTitle ] ] . position Y [ PName "price", PmType Quantitative ]@@ -515,8 +515,8 @@ xr = (Number 0.2, Number 6) yr = (Number (-0.8), Number 0.8) - xscale = [ SDomain (DSelectionField "brush" "theta") ]- yscale = [ SDomain (DSelectionChannel "brush" ChY) ]+ xscale = [ SDomainOpt (DSelectionField "brush" "theta") ]+ yscale = [ SDomainOpt (DSelectionChannel "brush" ChY) ] plot2 = asSpec [ encoding . position X [ PName "theta", PmType Quantitative, PScale xscale ]
tests/MarkTests.hs view
@@ -25,6 +25,7 @@ , ("pieChartWithLabels", pieChartWithLabels) , ("donutChart", donutChart) , ("radialChart", radialChart)+ , ("pyramidChart", pyramidChart) , ("histogram_binned_no_x2", histogramBinnedNoX2) ] @@ -226,6 +227,48 @@ . color [MName "data", MmType Nominal, MLegend []] $ [] , layer [asSpec plot, asSpec label]+ , viewBackground [VBNoStroke]+ ]+++-- https://vega.github.io/vega-lite/examples/arc_pie_pyramid.html+--+pyramidChart :: VegaLite+pyramidChart =+ let desc = description "Reproducing http://robslink.com/SAS/democd91/pyramid_pie.htm"+ dvals = dataFromColumns []+ . dataColumn "value" (Numbers [75, 10, 15])+ . dataColumn "order" (Numbers [3, 1, 2])+ . dataColumn "category" (Strings ["Sky", "Shady side of a pyramid", "Sunny side of a pyramid"])+ $ []++ cmap = [ ("Sky", "#416D9D")+ , ("Shady side of a pyramid", "#674028")+ , ("Sunny side of a pyramid", "#DEAC58")+ ]++ in toVegaLite [ desc+ , dvals+ , mark Arc [MOuterRadius 80]+ , encoding+ . position Theta [ PName "value"+ , PmType Quantitative+ , PScale [SRange (RPair 2.35619449 8.639379797)]+ -- How to get "stack": True???+ , PStack StZero+ ]+ . color [ MName "category"+ , MmType Nominal+ , MScale (categoricalDomainMap cmap)+ , MLegend [ LOrient LONone+ , LNoTitle+ , LColumns 1+ , LeX 200+ , LeY 80+ ]+ ]+ . order [OName "order"]+ $ [] , viewBackground [VBNoStroke] ]
tests/ScaleTests.hs view
@@ -20,6 +20,8 @@ , ("diverging1", diverging1) , ("diverging2", diverging2) , ("axisrange", axisrange)+ , ("axislimit", axislimit)+ , ("namedaxisrange", namedAxisRange) ] scale1 :: VegaLite@@ -206,21 +208,19 @@ diverging2 :: VegaLite diverging2 = toVegaLite [ divergingData- , divergingEnc [ SDomainMid 0 ]+ , divergingEnc [ SDomainOpt (DMid 0) ] , mark Bar [] ] -axisrange :: VegaLite-axisrange =+axes :: [ScaleProperty] -> [ScaleProperty] -> VegaLite+axes xscale yscale = let cars = dataFromUrl "https://vega.github.io/vega-lite/data/cars.json" [] - ax axis vals = [ PName axis, PmType Quantitative, PScale [SRange vals] ]- xrange = RWidth 50- yrange = RHeight 60+ ax axis vals = [ PName axis, PmType Quantitative, PScale vals ] enc = encoding- . position X (ax "Horsepower" xrange)- . position Y (ax "Miles_per_Gallon" yrange)+ . position X (ax "Horsepower" xscale)+ . position Y (ax "Miles_per_Gallon" yscale) . size [ MName "Acceleration", MmType Quantitative, MBin [] ] . opacity [ MName "Acceleration", MmType Quantitative, MBin [] ] @@ -228,3 +228,26 @@ , enc [] , mark Point [ MFilled True, MStroke "white", MStrokeWidth 0.4 ] ]+++axisrange, axislimit :: VegaLite+axisrange = axes [SRange (RWidth 50)] [SRange (RHeight 60)]+axislimit = axes+ [SDomainOpt (DMin (-10)), SDomainOpt (DMax 300)]+ [SRange (RMin 220), SRange (RMax 10)]+++-- Based on https://github.com/vega/vega-lite/issues/6392+--+namedAxisRange :: VegaLite+namedAxisRange =+ let dataVals = dataFromColumns []+ . dataColumn "col" (Strings ["X", "Y"])+ . dataColumn "l" (Strings ["A", "B"])+ . dataColumn "c" (Strings ["#ff0000", "#0000ff"])++ enc = encoding+ . position Y [PName "col", PmType Nominal]+ . color [MName "l", MmType Nominal, MScale [SRange (RField "c")]]++ in toVegaLite [dataVals [], mark Circle [], enc []]
+ tests/specs/conditional/selectionHeatMap.vl view
@@ -0,0 +1,120 @@+{+ "config": {+ "scale": {+ "bandPaddingInner": 0,+ "bandPaddingOuter": 0+ },+ "range": {+ "ramp": {+ "scheme": "yellowgreenblue"+ }+ },+ "view": {+ "step": 40+ },+ "axis": {+ "domain": false+ }+ },+ "mark": {+ "strokeWidth": 2,+ "type": "rect"+ },+ "data": {+ "values": [+ {+ "predicted": "A",+ "count": 13,+ "actual": "A"+ },+ {+ "predicted": "B",+ "count": 0,+ "actual": "A"+ },+ {+ "predicted": "C",+ "count": 0,+ "actual": "A"+ },+ {+ "predicted": "A",+ "count": 0,+ "actual": "B"+ },+ {+ "predicted": "B",+ "count": 10,+ "actual": "B"+ },+ {+ "predicted": "C",+ "count": 6,+ "actual": "B"+ },+ {+ "predicted": "A",+ "count": 0,+ "actual": "C"+ },+ {+ "predicted": "B",+ "count": 0,+ "actual": "C"+ },+ {+ "predicted": "C",+ "count": 9,+ "actual": "C"+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "selection": {+ "highlight": {+ "type": "single"+ }+ },+ "encoding": {+ "opacity": {+ "value": 0.5,+ "condition": {+ "value": 1,+ "selection": "highlight"+ }+ },+ "stroke": {+ "value": null,+ "condition": {+ "value": "black",+ "test": {+ "and": [+ {+ "selection": "highlight"+ },+ "length(data(\"highlight_store\"))"+ ]+ }+ }+ },+ "fill": {+ "field": "count",+ "type": "quantitative"+ },+ "x": {+ "field": "predicted",+ "type": "nominal"+ },+ "order": {+ "value": 0,+ "condition": {+ "value": 1,+ "selection": "highlight"+ }+ },+ "y": {+ "field": "actual",+ "type": "nominal"+ }+ }+}
+ tests/specs/gallery/bar/bar6order.vl view
@@ -0,0 +1,27 @@+{+ "mark": "bar",+ "data": {+ "url": "https://vega.github.io/vega-lite/data/barley.json"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "color": {+ "field": "site",+ "type": "nominal"+ },+ "x": {+ "field": "yield",+ "aggregate": "sum",+ "type": "quantitative"+ },+ "order": {+ "field": "yield",+ "aggregate": "sum",+ "type": "quantitative"+ },+ "y": {+ "field": "variety",+ "type": "nominal"+ }+ }+}
+ tests/specs/gallery/bar/bar6sort.vl view
@@ -0,0 +1,31 @@+{+ "transform": [+ {+ "as": "siteOrder",+ "calculate": "if(datum.site === 'University Farm', 0, if(datum.site === 'Grand Rapids', 1, 2))"+ }+ ],+ "mark": "bar",+ "data": {+ "url": "https://vega.github.io/vega-lite/data/barley.json"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "color": {+ "field": "site",+ "type": "nominal"+ },+ "x": {+ "field": "yield",+ "aggregate": "sum",+ "type": "quantitative"+ },+ "order": {+ "field": "siteOrder"+ },+ "y": {+ "field": "variety",+ "type": "nominal"+ }+ }+}
+ tests/specs/gallery/facet/facet_bullet.vl view
@@ -0,0 +1,189 @@+{+ "config": {+ "tick": {+ "thickness": 2+ }+ },+ "data": {+ "values": [+ {+ "measures": [+ 220,+ 270+ ],+ "markers": [+ 250+ ],+ "subtitle": "US$, in thousands",+ "ranges": [+ 150,+ 225,+ 300+ ],+ "title": "Revenue"+ },+ {+ "measures": [+ 21,+ 23+ ],+ "markers": [+ 26+ ],+ "subtitle": "%",+ "ranges": [+ 20,+ 25,+ 30+ ],+ "title": "Profit"+ },+ {+ "measures": [+ 100,+ 320+ ],+ "markers": [+ 550+ ],+ "subtitle": "US$, average",+ "ranges": [+ 350,+ 500,+ 600+ ],+ "title": "Order Size"+ },+ {+ "measures": [+ 1000,+ 1650+ ],+ "markers": [+ 2100+ ],+ "subtitle": "count",+ "ranges": [+ 1400,+ 2000,+ 2500+ ],+ "title": "New Customers"+ },+ {+ "measures": [+ 3.2,+ 4.7+ ],+ "markers": [+ 4.4+ ],+ "subtitle": "out of 5",+ "ranges": [+ 3.5,+ 4.25,+ 5+ ],+ "title": "Satisfaction"+ }+ ]+ },+ "resolve": {+ "scale": {+ "x": "independent"+ }+ },+ "spec": {+ "layer": [+ {+ "mark": {+ "color": "#eee",+ "type": "bar"+ },+ "encoding": {+ "x": {+ "field": "ranges[2]"+ }+ }+ },+ {+ "mark": {+ "color": "#ddd",+ "type": "bar"+ },+ "encoding": {+ "x": {+ "field": "ranges[1]"+ }+ }+ },+ {+ "mark": {+ "color": "#ccc",+ "type": "bar"+ },+ "encoding": {+ "x": {+ "field": "ranges[0]"+ }+ }+ },+ {+ "mark": {+ "color": "lightsteelblue",+ "size": 10,+ "type": "bar"+ },+ "encoding": {+ "x": {+ "field": "measures[1]"+ }+ }+ },+ {+ "mark": {+ "color": "steelblue",+ "size": 10,+ "type": "bar"+ },+ "encoding": {+ "x": {+ "field": "measures[0]"+ }+ }+ },+ {+ "mark": {+ "color": "black",+ "type": "tick"+ },+ "encoding": {+ "x": {+ "field": "markers[0]"+ }+ }+ }+ ],+ "encoding": {+ "x": {+ "scale": {+ "nice": false+ },+ "title": null,+ "type": "quantitative"+ }+ }+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "facet": {+ "row": {+ "field": "title",+ "header": {+ "labelAngle": 0,+ "title": null+ },+ "type": "ordinal"+ }+ },+ "spacing": 10+}
tests/specs/gallery/geo/geo7.vl view
@@ -115,8 +115,7 @@ "type": "quantitative" }, "order": {- "field": "order",- "type": "ordinal"+ "field": "order" } } }
tests/specs/gallery/line/line7.vl view
@@ -16,8 +16,7 @@ "type": "quantitative" }, "order": {- "field": "year",- "type": "temporal"+ "field": "year" }, "y": { "field": "gas",
+ tests/specs/scale/axislimit.vl view
@@ -0,0 +1,40 @@+{+ "mark": {+ "strokeWidth": 0.4,+ "stroke": "white",+ "type": "point",+ "filled": true+ },+ "data": {+ "url": "https://vega.github.io/vega-lite/data/cars.json"+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "size": {+ "field": "Acceleration",+ "bin": true,+ "type": "quantitative"+ },+ "opacity": {+ "field": "Acceleration",+ "bin": true,+ "type": "quantitative"+ },+ "x": {+ "field": "Horsepower",+ "scale": {+ "domainMax": 300,+ "domainMin": -10+ },+ "type": "quantitative"+ },+ "y": {+ "field": "Miles_per_Gallon",+ "scale": {+ "rangeMax": 10,+ "rangeMin": 220+ },+ "type": "quantitative"+ }+ }+}
+ tests/specs/scale/namedaxisrange.vl view
@@ -0,0 +1,33 @@+{+ "mark": "circle",+ "data": {+ "values": [+ {+ "l": "A",+ "col": "X",+ "c": "#ff0000"+ },+ {+ "l": "B",+ "col": "Y",+ "c": "#0000ff"+ }+ ]+ },+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",+ "encoding": {+ "color": {+ "field": "l",+ "scale": {+ "range": {+ "field": "c"+ }+ },+ "type": "nominal"+ },+ "y": {+ "field": "col",+ "type": "nominal"+ }+ }+}
tools/PlayTutorial.hs view
@@ -54,13 +54,29 @@ import System.Directory (createDirectoryIfMissing) import System.Environment (getArgs, getProgName) import System.Exit (exitFailure)-import System.FilePath ((</>), FilePath)+import System.FilePath ((</>)) import System.IO (hPutStrLn, stderr) import Prelude hiding (filter) -- Could use TH to get at the tutorials, but for now hard code the names. +-- The simple example used in the README+--+carData :: VegaLite+carData =+ let cars = dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []++ enc = encoding+ . position X [ PName "Horsepower", PmType Quantitative ]+ . position Y [ PName "Miles_per_Gallon", PmType Quantitative, PTitle "Miles per Gallon" ]+ . color [ MName "Origin" ]++ bkg = background "rgba(0, 0, 0, 0.05)"++ in toVegaLite [ bkg, cars, mark Circle [MTooltip TTEncoding], enc [] ]++ -- The intro visualization used in the API documentation (not in -- the tutorial). --@@ -76,12 +92,12 @@ w = width 600 h = height 150 - pos1Opts fld ttl = [PName fld, PmType Quantitative, PAxis [AxTitle ttl]]+ pos1Opts fld ttl = [PName fld, PmType Quantitative, PTitle ttl] x1Opts = pos1Opts "days" "Days since January 1, 2020" y1Opts = pos1Opts "magnitude" "Magnitude" ++ [PSort [Descending], yRange] yRange = PScale [SDomain (DNumbers [-1, 3])] - filtOpts = [MName "filterName", MmType Nominal]+ filtOpts = [MName "filterName"] filtEnc = color (MLegend [ LTitle "Filter", LTitleFontSize 16, LLabelFontSize 14 ] : filtOpts) . shape filtOpts @@ -93,8 +109,8 @@ . filtEnc selName = "brush"- pos2Opts fld = [PName fld, PmType Quantitative, PAxis [AxNoTitle],- PScale [SDomain (DSelectionField selName fld)]]+ pos2Opts fld = [PName fld, PmType Quantitative, PNoTitle,+ PScale [SDomainOpt (DSelectionField selName fld)]] x2Opts = pos2Opts "days" y2Opts = pos2Opts "magnitude" ++ [PSort [Descending]] @@ -132,7 +148,6 @@ details = asSpec [ columns 1 , facetFlow [ FName "filterName"- , FmType Nominal , FHeader headerOpts ] , spacing 10@@ -161,10 +176,12 @@ -- vl :: [(String, VegaLite)] vl = [ ("api-betelgeuse", betelgeuse)+ , ("api-cardata", carData) , ("stripplot", VL.stripPlot) , ("stripplotwithbackground", VL.stripPlotWithBackground) , ("stripploty", VL.stripPlotY) , ("stripplotwithcolor", VL.stripPlotWithColor)+ , ("stripplotwithcolor2", VL.stripPlotWithColor2) , ("stripplotwithcolorordinal", VL.stripPlotWithColorOrdinal) , ("piechart", VL.pieChart) , ("piechartwithcounting", VL.pieChartWithCounting)