hvega

Create Vega and Vega-Lite visualizations.

https://github.com/DougBurke/hvega

Version on this page:0.1.0.3
LTS Haskell 22.43:0.12.0.7
Stackage Nightly 2024-12-05:0.12.0.7
Latest on Hackage:0.12.0.7

See all snapshots hvega appears in

BSD-3-Clause licensed by Douglas Burke
Maintained by [email protected]
This version can be pinned in stack with:hvega-0.1.0.3@sha256:4b08eb6ce092b1c275b90c071ffb6a68c4cf0b15bd7e7aaf7245cefe36dfc629,1311

Module documentation for 0.1.0.3

Depends on 4 packages(full list with versions):
Used by 1 package in lts-11.22(full list with versions):

hvega

Support the creation of Vega-Lite visualizations in Haskell. This code is released under the BSD3 license.

It is an almost-direct copy of version 2.2.1 of the Elm Vega library, which is released under a BSD3 license by Jo Wood of the giCentre at the City University of London.

Example

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 ]
            . color [ MName "Origin", MmType Nominal ]

    bkg = background "rgba(0, 0, 0, 0.05)"

in toVegaLite [ bkg, cars, mark Circle [], enc [] ]

When viewed with a Vega-Lite aware viewer, the resultant plot is

Simple scatterplot

Documentation

The Elm Vega documentation can be used as a guide to using this module. The Vega-Lite Example Gallery has been converted to an IHaskell notebook (unfortunately the plots created by VegaEmbed do not appear in the notebook when viewed with either GitHub’s viewer or ipynb viewer).

Differences to Elm Vega

The main changes to version 2.2.1 of Elm Vega 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).

Changes

For the latest version of this document, please see https://github.com/DougBurke/hvega/blob/master/hvega/CHANGELOG.md.

0.1.0.3

The only change is to the cabal file, where cabal-version: >=1.18 has been changed to cabal-version: 1.18.

0.1.0.2

Updated the upper bounds of aeson to really allow v1.4. This was not released on Hackage.

0.1.0.1

Updated the upper bounds of aeson from v1.2 to v1.4.

The cabal package now includes stack.yaml and default.nix (although the latter is not guaranteed to be correct), as well as a change log and an extra image.

0.1.0.0

This is the initial version of hvega, which is based on version 2.2.1 of the Elm Vega library.