hvega 0.9.0.1 → 0.9.1.0
raw patch · 8 files changed
+152/−12 lines, 8 filesbinary-addedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Graphics.Vega.Tutorials.VegaLite: pieChart :: VegaLite
+ Graphics.Vega.Tutorials.VegaLite: pieChartWithCounting :: VegaLite
Files
- CHANGELOG.md +5/−0
- hvega.cabal +3/−1
- hvega.nix +8/−2
- images/vl/piechart.png binary
- images/vl/piechartwithcounting.png binary
- src/Graphics/Vega/Tutorials/VegaLite.hs +129/−9
- src/Graphics/Vega/VegaLite.hs +5/−0
- tools/PlayTutorial.hs +2/−0
CHANGELOG.md view
@@ -1,6 +1,11 @@ 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.9.1.0++The tutorial has been expanded to add a section describing the+new pie chart support (the Arc mark).+ ## 0.9.0.1 The introductory text of the module has been updated to start
hvega.cabal view
@@ -1,5 +1,5 @@ name: hvega-version: 0.9.0.1+version: 0.9.1.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>)@@ -68,6 +68,8 @@ images/vl/stripploty.png images/vl/stripplotwithcolor.png images/vl/stripplotwithcolorordinal.png+ images/vl/piechart.png+ images/vl/piechartwithcounting.png images/vl/parallaxbreakdown.png images/vl/parallaxhistogram.png images/vl/gmaghistogram.png
hvega.nix view
@@ -1,13 +1,19 @@ { mkDerivation, aeson, aeson-pretty, base, bytestring, containers-, filepath, stdenv, tasty, tasty-golden, text, unordered-containers+, directory, filepath, http-conduit, stdenv, tagsoup, tasty+, tasty-golden, text, unordered-containers }: mkDerivation { pname = "hvega";- version = "0.9.0.1";+ version = "0.9.1.0"; src = ./.;+ configureFlags = [ "-ftools" ]; isLibrary = true; isExecutable = true; libraryHaskellDepends = [ aeson base text unordered-containers ];+ executableHaskellDepends = [+ aeson aeson-pretty base bytestring directory filepath http-conduit+ tagsoup text+ ]; testHaskellDepends = [ aeson aeson-pretty base bytestring containers filepath tasty tasty-golden text unordered-containers
+ images/vl/piechart.png view
binary file changed (absent → 14659 bytes)
+ images/vl/piechartwithcounting.png view
binary file changed (absent → 14794 bytes)
src/Graphics/Vega/Tutorials/VegaLite.hs view
@@ -19,7 +19,7 @@ <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.5.0.0@ of hvega.+the functionality provided in version @0.9.0.0@ of hvega. -} @@ -82,6 +82,13 @@ , stripPlotWithColorOrdinal + -- * A Pie Chart+ --+ -- $pie-chart++ , pieChart+ , pieChartWithCounting+ -- * Adding an axis -- -- $add-axis@@ -632,7 +639,7 @@ 'dataFromRows' - or directly from JSON (as a 'Data.Aeson.Value') using 'dataFromJson'. -An example showing 'dataFromColumns' is the 'skyPlotWithGraticules' plot,+Examples showing 'dataFromColumns' are the 'pieChart' and'skyPlotWithGraticules' plots, but let's not peak ahead! -}@@ -737,6 +744,120 @@ , enc [] ] ++-- $pie-chart+-- Before adding a second axis, let's temporarily look at another+-- \"one dimensiona" chart, namel the humble pie chart.+-- The 'Arc' mark type allows you to create pie charts, as well as more+-- complex visualizations which we won't discuss further in this+-- tutorial.+++{-|++In this example we embed the data for the pie chart - namely the number+of stars per cluster - in the vsualization itself (using+'dataFromColumns' to create column data labelled \"cluster\" and+\"count\"). The 'position' encoding is set to 'Theta', which is+given the star counts, and the 'color' is set to the+Cluster name.++<<images/vl/piechart.png>>++<https://vega.github.io/editor/#/url/vega-lite/N4IgtghgTg1iBcJoGMQBoQBMIBcINADcIAbAVwFMBnBAbVGXKpwqgSRIAcALCAAgAKrdCGQB7MgDscCAOwAWAAwBfNAyYs2iAEIkIk8XwCMI8VJnx5ADgCcq9WWbDEAYTGQ+24RjPSERgFYAZntRDWcQAAkATwhMalMJP3gAwNDGR012AEkXPgAmIJsTHySLIPyA9PCtEFyCgDZFfMTzBHkbfOrMiIA5AHE8-PlU1uSlFTUwntqBEgoASziE0rb4IwqG7qdZqAhqCk4KMYsbIKtlAF1VEAASKmRuCkh2bhwcTip4AHpvwgoAOYQAB0AIWOG4ZAARsCFmJvg8npA-oCIABaEjgih-eTAgBWVDEkhEFAMYkwC0kAIIIAhFDwNIAZgsKCRMOxfDIMDhokd2ABHMj6HDg3ALf4gG7iEhiLSgZms9mIDI7EQ8vmISTuSmkSXKZRAA Open this visualization in the Vega Editor>++@+let manualData = 'dataFromColumns' []+ . 'dataColumn' "cluster" ('Strings' clusters)+ . dataColumn "count" ('Numbers' counts)+ $ []++ clusters = [ \"alpha Per\", \"Blanco 1\", \"Coma Ber\", \"Hyades\", \"IC 2391\"+ , \"IC 2602\", \"NGC 2451\", \"Pleiades\", \"Praesepe\"]+ counts = [ 740, 489, 153, 515, 325, 492, 400, 1326, 938]++ enc = encoding+ . position 'Theta' [PName "count", PmType Quantitative]+ . color [MName "cluster", MmType Nominal]++in toVegaLite+ [ manualData+ , mark 'Arc' []+ , enc []+ ]+@++-}++pieChart :: VegaLite+pieChart =+ let manualData = dataFromColumns []+ . dataColumn "cluster" (Strings clusters)+ . dataColumn "count" (Numbers counts)+ $ []++ clusters = [ "alpha Per", "Blanco 1", "Coma Ber", "Hyades", "IC 2391"+ , "IC 2602", "NGC 2451", "Pleiades", "Praesepe"]+ counts = [ 740, 489, 153, 515, 325, 492, 400, 1326, 938]++ enc = encoding+ . position Theta [PName "count", PmType Quantitative]+ . color [MName "cluster", MmType Nominal]++ in toVegaLite+ [ manualData+ , mark Arc []+ , enc []+ ]+++{-|++There are three main changes to 'pieChart':++ - 'MInnerRadius' is used to impose a minimum radius on the pie slices+ (so leaving a hole in the center);++ - the 'ViewStyle' configuration is used to turn off the plot edge;++ - and the count value is calculated automatically by the 'PAggregate'+ method (summing over the \"Cluster\" column), rather than having a+ hand-generated table of values encoded in the visualization.++<<images/vl/piechartwithcounting.png>>++<https://vega.github.io/editor/#/url/vega-lite/N4Igxg9gdgZglgcxALlANzgUwO4tAZwBcAnCAa0xSgFcAbWgXwYBoQBbAQ2LLxEIE8ADpWQguYEKzhQomYgCUOAEzjV8KAEwAGFiCUdCHXtWK0UIABaFCg-MgD094h2wA6BHEIXqAIzVzIKEJMINdINnsAEQhqBAAhEwp7CzRMBA57TiI5ZNT0+31De3S4DgBaDnKANgBGKoqarTLDH1pMGo5XKAgyi0xlOVdCfDRJEBgIYk5CXkEufBFQAHFOJFEaNh85MfkAQQB9AEkAYXkAZXMNreIxwVoAD0vqTe3WSIBRI9OL9efrscw+zuj1+LxuTF0ABJ8GA+pxzFYbHZHHlOh4vL5XHAIPYYXCMqiyrRPJh7GgACyuABW+GgAKgkBUUDWoC8mEMvA4CAQxDSBhE4BiQTGAmE5gAjtQOEFPAY4KkQLpILRJrx4JhaEpzMdaGpgjdWKKBd02NIOGYIUA Open this visualization in the Vega Editor> ++@+let enc = encoding+ . position Theta ['PAggregate' 'Count', PmType Quantitative]+ . color [MName "Cluster", MmType Nominal]++in toVegaLite+ [ gaiaData+ , mark Arc ['MInnerRadius' 20]+ , enc []+ , configure (configuration ('ViewStyle' ['ViewNoStroke']) [])+ ]+@++-}+++pieChartWithCounting :: VegaLite+pieChartWithCounting =+ let enc = encoding+ . position Theta [PAggregate Count, PmType Quantitative]+ . color [MName "Cluster", MmType Nominal]++ in toVegaLite+ [ gaiaData+ , mark Arc [MInnerRadius 20]+ , enc []+ , configure (configuration (ViewStyle [ViewNoStroke]) [])+ ]++ -- $add-axis -- While the strip plot shows the range of parallaxes, it is hard to -- make out the distribution of values, since the ticks overlap. Even@@ -746,7 +867,6 @@ -- axis is easy to do, so let's see how the parallax distribution -- varies with cluster membership. - {-| The 'stripPlotWithColor' visualization can be changed to show two@@ -824,7 +944,7 @@ simpleHistogram field = let enc = encoding . position X [ PName field, PmType Quantitative, 'PBin' [] ]- . position Y [ 'PAggregate' 'Count', PmType Quantitative ]+ . position Y [ PAggregate Count, PmType Quantitative ] in toVegaLite [ gaiaData@@ -973,7 +1093,7 @@ . color [ MName \"Cluster\", MmType Nominal ] binning = PBin [ 'Step' 1 ]- axis = PAxis [ 'AxValues' ('Numbers' [ 0, 5 .. 20 ]) ]+ axis = PAxis [ 'AxValues' (Numbers [ 0, 5 .. 20 ]) ] in toVegaLite [ gaiaData@@ -2410,7 +2530,7 @@ labelSpec = asSpec [ labelEnc [], mark 'Text' [ 'MdY' (-6) ] ] cfg = configure- . configuration ('ViewStyle' ['ViewNoStroke'])+ . configuration (ViewStyle [ViewNoStroke]) in toVegaLite [ width 300 , height 250@@ -2538,10 +2658,10 @@ , mark Geoshape [ ] ] - raData = 'dataFromColumns' []- . 'dataColumn' "x" (Numbers [ -120, -60, 60, 120 ])+ raData = dataFromColumns []+ . dataColumn "x" (Numbers [ -120, -60, 60, 120 ]) . dataColumn "y" (Numbers [ 0, 0, 0, 0 ])- . dataColumn "lbl" ('Strings' [ "16h", "20h", "4h", "8h" ])+ . dataColumn "lbl" (Strings [ "16h", "20h", "4h", "8h" ]) decData = dataFromColumns [] . dataColumn "x" (Numbers [ 0, 0 ])
src/Graphics/Vega/VegaLite.hs view
@@ -857,6 +857,8 @@ -- ** Version 0.9 --+ -- $update0910+ -- -- $update0900 -- ** Version 0.8@@ -1254,6 +1256,9 @@ -- $update -- The following section describes how to update code that used -- an older version of @hvega@.++-- $update0910+-- The tutorial has been expanded to add a section with pie charts. -- $update0900 -- The @0.9.0.0@ release updates @hvega@ to support version 4.12 of
tools/PlayTutorial.hs view
@@ -166,6 +166,8 @@ , ("stripploty", VL.stripPlotY) , ("stripplotwithcolor", VL.stripPlotWithColor) , ("stripplotwithcolorordinal", VL.stripPlotWithColorOrdinal)+ , ("piechart", VL.pieChart)+ , ("piechartwithcounting", VL.pieChartWithCounting) , ("parallaxbreakdown", VL.parallaxBreakdown) , ("parallaxhistogram", VL.parallaxHistogram) , ("gmaghistogram", VL.gmagHistogram)