gicentre/elm-vega/2.3.0

NOTE: this package is not compatible with Elm 0.19.1

VegaLite

This module allows you to create Vega-Lite specifications in Elm. A specification is stored as a JSON object which can be sent to a Vega-Lite compiler to generate the graphics. While this a 'pure' Elm library, to create the graphical output you probably want to send a Vega-Lite specification generated by toVegaLite via a port to some JavaScript that invokes the Vega-Lite runtime.

Creating A Vega-Lite Specification

toVegaLite : List ( VLProperty, Spec ) -> Spec

Convert a list of Vega-Lite specifications into a single JSON object that may be passed to Vega-Lite for graphics generation. Commonly these will include at least a data, mark and encoding specification.

While simple functions like bar may be provided directly, it is usually clearer to label more complex ones such as encodings as separate expressions. This becomes increasingly helpful for visualizations that involve composition of layers, repeats and facets.

Specifications can be built up by chaining a series of functions (such as dataColumn or position in the example below). Functional composition using the << operator allows this to be done compactly.

let
    data =
        dataFromColumns []
            << dataColumn "a" (strs [ "C", "C", "D", "D", "E", "E" ])
            << dataColumn "b" (nums [ 2, 7, 1, 2, 6, 8 ])


    enc =
        encoding
            << position X [ pName "a", pMType Nominal ]
            << position Y [ pName "b", pMType Quantitative, pAggregate Mean ]
in
toVegaLite [ data [], bar [], enc [] ]

Top-level Vega-Lite properties. These are the ones that define the core of the visualization grammar. All VLProperties are created by functions which can be arranged into seven broad groups.

Data Properties relate to the input data to be visualized. Generated by dataFromColumns, dataFromRows, dataFromUrl, dataFromSource and dataFromJson.

Transform Properties indicate that some transformation of input data should be applied before encoding them visually. Generated by transform and projection they can include data transformations such as filter, binAs and calculateAs and geo transformations of longitude, latitude coordinates used by marks such as those generated by geoshape, point and line.

Mark Functions relate to the symbols used to visualize data items. Generated by functions such as circle, bar and line.

Encoding Properties specify which data elements are mapped to which mark characteristics (known as channels). Generated by encoding they include encodings such as position, color, size, shape text and hyperlink.

Composition Properties allow visualization views to be combined to form more complex visualizations. Generated by layer, repeat, facet, hConcat, vConcat, spec and resolve.

Interaction Properties allow interactions such as clicking, dragging and others generated via a GUI or data stream to influence the visualization. Generated by selection.

Supplementary and Configuration Properties provide a means to add metadata and styling to one or more visualizations. Generated by name, title, description, background, width, height, padding, autosize and configure.

type alias Spec =
Value

Represents part or all of Vega-Lite specification. Specs can be (and usually are) nested. They can range from a single Boolean value up to the entire Vega-Lite specification.

type alias LabelledSpec =
( String, Spec )

Represents a named Vega-Lite specification, usually generated by an elm-vega function. You shouldn't need to create LabelledSpec tuples directly, but they can be useful for type annotations.

combineSpecs : List LabelledSpec -> Spec

Combines a list of labelled specifications into a single specification that may be passed to JavaScript for rendering. This is useful when you wish to create a single page with multiple visulizualizations.

combineSpecs
    [ ( "vis1", myFirstVis )
    , ( "vis2", mySecondVis )
    , ( "vis3", myOtherVis )
    ]

Creating the Data Specification

Functions and types for declaring the input data to the visualization.

dataFromUrl : String -> List Format -> Data

Declare data source from a url. The URL can be a local path on a web server or an external http(s) URL. Used to create a data ( property, specification ) pair. An optional list of field formatting instructions can be provided as the second parameter or an empty list to use the default formatting. See the Vega-Lite documentation for details.

enc = ...
toVegaLite
    [ dataFromUrl "data/weather.csv" [ parse [ ( "date", foDate "%Y-%m-%d %H:%M" ) ] ]
    , line []
    , enc []
    ]
dataFromColumns : List Format -> List DataColumn -> Data

Declare a data source from a provided list of column values. Each column contains values of the same type, but columns each with a different type are permitted. Columns should all contain the same number of items; if not the dataset will be truncated to the length of the shortest column. An optional list of field formatting instructions can be provided as the first parameter or an empty list to use the default formatting. See the Vega-Lite documentation for details. The columns themselves are most easily generated with dataColumn

data =
    dataFromColumns [ parse [ ( "Year", foDate "%Y" ) ] ]
        << dataColumn "Animal" (strs [ "Fish", "Dog", "Cat" ])
        << dataColumn "Age" (nums [ 28, 12, 6 ])
        << dataColumn "Year" (strs [ "2010", "2014", "2015" ])
dataFromRows : List Format -> List DataRow -> Data

Declare a data source from a provided list of row values. Each row contains a list of tuples where the first value is a string representing the column name, and the second the column value for that row. Each column can have a value of a different type but you must ensure that when subsequent rows are added, they match the types of previous values with shared column names. An optional list of field formatting instructions can be provided as the first parameter or an empty list to use the default formatting. See the Vega-Lite documentation for details. The rows themselves are most easily generated with dataRow. Note though that generally if you are creating data inline (as opposed to reading from a file), adding data by column is more efficient and less error-prone.

data =
    dataFromRows [ parse [ ( "Year", foDate "%Y" ) ] ]
        << dataRow [ ( "Animal", str "Fish" ), ( "Age", num 28 ), ( "Year", str "2010" ) ]
        << dataRow [ ( "Animal", str "Dog" ), ( "Age", num 12 ), ( "Year", str "2014" ) ]
        << dataRow [ ( "Animal", str "Cat" ), ( "Age", num 6 ), ( "Year", str "2015" ) ]
dataFromJson : Spec -> List Format -> Data

Declare a data source from a provided json specification. The most likely use-case for specifying json inline is when creating geojson objects, when geometry, geometryCollection and geoFeatureCollection functions may be used. For more general cases of json creation, consider Json.Encode.

let
    geojson =
        geometry (geoPolygon [ [ ( -3, 59 ), ( 4, 59 ), ( 4, 52 ), ( -3, 59 ) ] ]) []
in
toVegaLite
    [ width 200
    , height 200
    , dataFromJson geojson []
    , projection [ prType Orthographic ]
    , geoshape []
    ]
dataFromSource : String -> List Format -> Data

Declare data from a named source. The source may be from named datasets within a specification or a named data source created via the Vega View API. An optional list of field formatting instructions can be provided as the second parameter or an empty list to use the default formatting. See the Vega-Lite documentation for details.

data = ...
json = ...
enc = ...
toVegaLite
    [ datasets [ ( "myData", data [] ),  ( "myJson", dataFromJson json [] ) ]
    , dataFromSource "myData" []
    , bar []
    , enc []
    ]
datasets : List ( String, Data ) -> Data

Create a dataset comprising a collection of named Data items. Each data item can be created with normal data generating functions such as dataFromRows or dataFromJson. These can be later referred to using dataFromSource.

import Json.Encode as JE


let
    data =
        dataFromRows []
            << dataRow [ ( "cat", str "a" ), ( "val", num 10 ) ]
            << dataRow [ ( "cat", str "b" ), ( "val", num 18 ) ]
    json =
        JE.list
            [ JE.object [ ( "cat", JE.string "a" ), ( "val", JE.float 120 ) ]
            , JE.object [ ( "cat", JE.string "b" ), ( "val", JE.float 180 ) ]
            ]


    enc = ...


in
toVegaLite
    [ datasets [ ( "myData", data [] ),  ( "myJson", dataFromJson json [] ) ]
    , dataFromSource "myData" []
    , bar []
    , enc []
    ]
dataColumn : String -> DataValues -> List DataColumn -> List DataColumn

Create a column of data. A column has a name and a list of values. The final parameter is the list of any other columns to which this is added.

dataColumn "Animal" (strs [ "Cat", "Dog", "Mouse"]) []
dataRow : List ( String, DataValue ) -> List DataRow -> List DataRow

Create a row of data. A row comprises a list of (columnName,value) pairs. The final parameter is the list of any other rows to which this is added.

dataRow [ ("Animal", str "Fish"), ("Age", num 28), ("Year", str "2010") ] []
type alias Data =
( VLProperty, Spec )

Convenience type annotation label for use with data generation functions.

myRegion : List DataColumn -> Data
myRegion =
    dataFromColumns []
        << dataColumn "easting" (nums [ -3, 4, 4, -3, -3 ])
        << dataColumn "northing" (nums [ 52, 52, 45, 45, 52 ])
type alias DataColumn =
List LabelledSpec

Represents a single column of data. Used when generating inline data with dataColumn.

type alias DataRow =
Spec

Represents a single row of data. Used when generating inline data with dataRow.

Geographic Data

geometry : Geometry -> List ( String, DataValue ) -> Spec

Specifies a geometric object to be used in a geoshape specification. The first parameter is the geometric type, the second an optional list of properties to be associated with the object.

  geojson =
      geometry (geoPolygon [ [ ( -3, 59 ), ( 4, 59 ), ( 4, 52 ), ( -3, 59 ) ] ]) []
geoFeatureCollection : List Spec -> Spec

Specifies a list of geo features to be used in a geoshape specification. Each feature object in this collection can be created with the geometry function.

geojson =
    geoFeatureCollection
        [ geometry (geoPolygon [ [ ( -3, 59 ), ( -3, 52 ), ( 4, 52 ), ( -3, 59 ) ] ])
            [ ( "myRegionName", str "Northern region" ) ]
        , geometry (geoPolygon [ [ ( -3, 52 ), ( 4, 52 ), ( 4, 45 ), ( -3, 52 ) ] ])
            [ ( "myRegionName", str "Southern region" ) ]
        ]
geometryCollection : List Spec -> Spec

Specifies a list of geometry objects to be used in a geoshape specification. Each geometry object in this collection can be created with the geometry function.

geojson =
    geometryCollection
        [ geometry (geoPolygon [ [ ( -3, 59 ), ( 4, 59 ), ( 4, 52 ), ( -3, 59 ) ] ]) []
        , geometry (geoPoint -3.5 55.5) []
        ]
geoPoint : Float -> Float -> Geometry

Specify point geometry for programmatically creating GeoShapes. This is equivalent to the GeoJson geometry point type in the GeoJSON specification.

geoPoints : List ( Float, Float ) -> Geometry

Specify multi-point geometry for programmatically creating GeoShapes. This is equivalent to the GeoJson geometry multi-point type in the GeoJSON specification.

geoLine : List ( Float, Float ) -> Geometry

Specify line geometry for programmatically creating GeoShapes. This is equivalent to the GeoJson geometry line type in the GeoJSON specification.

geoLines : List (List ( Float, Float )) -> Geometry

Specify multi-line geometry for programmatically creating GeoShapes. This is equivalent to the GeoJson geometry multi-line type in the GeoJSON specification.

geoPolygon : List (List ( Float, Float )) -> Geometry

Specify polygon geometry for programmatically creating GeoShapes. This is equivalent to the GeoJson geometry polygon type in the GeoJSON specification.

geoPolygons : List (List (List ( Float, Float ))) -> Geometry

Specify multi-polygon geometry for programmatically creating GeoShapes. This is equivalent to the GeoJson geometry multi-polygon type in the GeoJSON specification.

= FoNumber
| FoBoolean
| FoDate String
| FoUtc String

Indicates the type of data to be parsed when reading input data. When parsing dates, you should use the foDate or foUtc functions rather than their equivalent (deprecated) type constructors.

Formating Input Data

type Format
= JSON String
| CSV
| TSV
| TopojsonFeature String
| TopojsonMesh String
| Parse (List ( String, DataType ))

Specifies the type of format a data source uses. If the format is indicated by the file name extension (.tsv, .csv, .json) there is no need to indicate the format explicitly. However this can be useful if the filename extension does not indicate type (e.g. .txt). To customise the parsing of a file use one of the functions parse, jsonProperty, topojsonFeature or topojsonMesh in preference to their (depcrecated) type constructor equivalents. For details see the Vega-Lite documentation.

jsonProperty : String -> Format

Indicates a JSON file format from which a given property is to be extracted when it has some surrounding structure or meta-data. For example, specifying the property values.features is equivalent to retrieving json.values.features from the loaded JSON object with a custom delimeter. For details, see the Vega-Lite JSON documentation.

topojsonFeature : String -> Format

Indicates a topoJSON feature format. The first parameter should be the name of the object set to extract. Typically used when specifying a data url.

topojsonMesh : String -> Format

Indicates a topoJSON mesh format. The first parameter should be the name of the object set to extract. Unlike the topojsonFeature, the corresponding geo data are returned as a single, unified mesh instance, not as individual GeoJSON features. Typically used when specifying a data url.

parse : List ( String, DataType ) -> Format

Indicates the parsing rules when processing some data text. The parameter is a list of tuples where each corresponds to a field name paired with its desired data type. Typically used when specifying a data url.

foDate : String -> DataType

Specity a date format for parsing input data. Formatting can be specified using D3's formatting specifiers or left as an empty string if default date formatting is to be applied. Care should be taken when assuming default parsing of dates because different browsers can parse dates differently. Being explicit about the date format is usually safer.

foUtc : String -> DataType

Specity a UTC date format for parsing input data. Formatting can be specified using D3's formatting specifiers or left as an empty string if default date formatting is to be applied. Care should be taken when assuming default parsing of UTC dates because different browsers can parse dates differently. Being explicit about the date format is usually safer.

Creating the Transform Specification

Functions and types for declaring the transformation rules that are applied to data fields or geospatial coordinates before they are encoded visually.

transform : List LabelledSpec -> ( VLProperty, Spec )

Create a single transform from a list of transformation specifications. Note that the order of transformations can be important, especially if labels created with calculateAs, timeUnitAs and binAs are used in other transformations. Using the functional composition pipeline idiom (as example below) allows you to provide the transformations in the order intended in a clear manner.

trans =
    transform
        << filter (fiExpr "datum.year == 2010")
        << calculateAs "datum.sex == 2 ? 'Female' : 'Male'" "gender"

Map Projections

projection : List ProjectionProperty -> ( VLProperty, Spec )

Sets the cartographic projection used for geospatial coordinates. A projection defines the mapping from (longitude,latitude) to an (x,y) plane used for rendering. This is useful when using the Geoshape mark. For further details see the Vega-Lite documentation.

proj =
    projection [ prType Orthographic, prRotate -40 0 0 ]
prType : Projection -> ProjectionProperty

Specify the type of global map projection to use in a projection transformation. For details see the Vega-Lite projection documentation

prClipAngle : Maybe Float -> ProjectionProperty

Specify a projection’s clipping circle radius to the specified angle in degrees. A value of Nothing will switch to antimeridian cutting rather than small-circle clipping. For details see the Vega-Lite projection documentation

prClipExtent : ClipRect -> ProjectionProperty

Specify a projection’s viewport clip extent to the specified bounds in pixels. For details see the Vega-Lite projection documentation

prCenter : Float -> Float -> ProjectionProperty

Specify a projection’s center as longitude and latitude in degrees. The default value is 0,0. For details see the Vega-Lite projection documentation

prRotate : Float -> Float -> Float -> ProjectionProperty

Specify a projection’s three-axis rotation angle. This should be in order lambda phi gamma specifying the rotation angles in degrees about each spherical axis (corresponding to yaw, pitch and roll.). For details see the Vega-Lite projection documentation

prPrecision : Float -> ProjectionProperty

Specify a threshold for the projection’s adaptive resampling in pixels. This corresponds to the Douglas–Peucker distance. If precision is not specified, the projection’s current resampling precision which defaults to √0.5 ≅ 0.70710 is used. For details see the Vega-Lite projection documentation

prCoefficient : Float -> ProjectionProperty

Specify a 'Hammer' map projection coefficient. For details see the Vega-Lite projection documentation

prDistance : Float -> ProjectionProperty

Specify a 'Satellite' map projection distance. For details see the Vega-Lite projection documentation

prFraction : Float -> ProjectionProperty

Specify a Bottomley map projection fraction. For details see the Vega-Lite projection documentation

prLobes : Int -> ProjectionProperty

Specify the number of lobes in lobed map projections such as the 'Berghaus star'. For details see the Vega-Lite projection documentation

prParallel : Float -> ProjectionProperty

Specify a parallel for map projections such as the 'Armadillo'. For details see the Vega-Lite projection documentation

prRadius : Float -> ProjectionProperty

Specify a radius value for map projections such as the 'Gingery'. For details see the Vega-Lite projection documentation

prRatio : Float -> ProjectionProperty

Specify a ratio value for map projections such as the 'Hill'. For details see the Vega-Lite projection documentation

prSpacing : Float -> ProjectionProperty

Specify a spacing value for map projections such as the 'Lagrange'. For details see the Vega-Lite projection documentation

prTilt : Float -> ProjectionProperty

Specify a 'Satellite' map projection tilt. For details see the Vega-Lite projection documentation

= Albers
| AlbersUsa
| AzimuthalEqualArea
| AzimuthalEquidistant
| ConicConformal
| ConicEqualArea
| ConicEquidistant
| Custom String
| Equirectangular
| Gnomonic
| Mercator
| Orthographic
| Stereographic
| TransverseMercator

Types of geographic map projection. These are based on a subset of those provided by the d3-geo library. For details of available projections see the Vega-Lite documentation.

Note: The use of the Custom type constructor is deprecated in favour of the customProjection function.

customProjection : String -> Projection

Specify a custom projection type. Additional custom projections from d3 can be defined via the Vega API and called from with this function where the parameter is the name of the D3 projection to use (e.g. customProjection "winkel3").

= NoClip
| LTRB Float Float Float Float

Specifies whether or not a clipping rectangle is to be applied. If it is, the function clipRect should be called rather than the (deprecated) type constructor LTRB.

clipRect : Float -> Float -> Float -> Float -> ClipRect

Specify a clipping rectangle in pixel units. The four parameters are respectively 'left', 'top', 'right' and 'bottom' of the rectangular clipping bounds.

Aggregation

aggregate : List Spec -> List String -> List LabelledSpec -> List LabelledSpec

Defines a set of named aggregation transformations to be used when encoding channels. This is useful when, for example, you wish to apply the same transformation to a number of channels but do not want to define it each time. The first parameter is a list of the named aggregation operations to apply. The second parameter is a list of 'group by' fields. The third parameter is the list of transformations to which this is to be added. For further details see the Vega-Lite documentation.

trans =
    transform
        << aggregate
            [ opAs Min "people" "lowerBound", opAs Max "people" "upperBound" ]
            [ "age" ]
= ArgMax
| ArgMin
| Average
| CI0
| CI1
| Count
| Distinct
| Max
| Mean
| Median
| Min
| Missing
| Q1
| Q3
| Stderr
| Stdev
| StdevP
| Sum
| Valid
| Variance
| VarianceP

Type of aggregation operation. See the Vega-Lite documentation for more details.

opAs : Operation -> String -> String -> Spec

Create a named aggregation operation on a field that can be added to a transformation. The first parameter is the aggregation operation to use; the second the name of the field in which to apply it and the third the name to be given to this transformation. For further details see the Vega-Lite documentation.

trans =
    transform
        << aggregate
            [ opAs Min "people" "lowerBound"
            , opAs Max "people" "upperBound"
            ]
            [ "age" ]
timeUnitAs : TimeUnit -> String -> String -> List LabelledSpec -> List LabelledSpec

Creates a new data field based on the given temporal binning. Unlike the direct encoding binning, this transformation is named and so can be referred to in multiple encodings. The first parameter is the 'width' of each temporal bin, the second is the field to bin and the third is name to give the newly binned field. The final, often implicit, parameter is a list of previous transformations to which this is added. Note though that usually it is easer to apply the temporal binning directly as part of the encoding as this will automatically format the temporal axis. See the Vega-Lite documentation for further details.

The following example takes a temporal dataset and encodes daily totals from it grouping by month.

trans =
    transform << timeUnitAs Month "date" "monthly"


enc =
    encoding
        << position X [ pName "date", pMType Temporal, pTimeUnit Day ]
        << position Y [ pAggregate Sum, pMType Quantitative ]
        << detail [ dName "monthly", dMType Temporal ]

Binning

List BinProperty
-> String
-> String
-> List LabelledSpec
-> List LabelledSpec

Create a named binning transformation that may be referenced in other Transformations or encodings. The type of binning can be customised with a list of BinProperty generating functions (biBase, biDivide etc.) or an empty list to use the default binning. For more details, see the Vega-Lite documentation.

trans =
    transform
        << binAs [ MaxBins 3 ] "IMDB_Rating" "ratingGroup"

Note that usually, direct binning within an encoding is preferred over this form of bin transformation.

biBase : Float -> BinProperty

Specify the number base to use for automatic bin determination (default is base 10). For more details, see the Vega-Lite binning documentation

biDivide : List Float -> BinProperty

Specify the scale factors indicating allowable subdivisions for binning. The default value is [5, 2], which indicates that for base 10 numbers (the default base), binning will consider dividing bin sizes by 5 and/or 2. For more details, see the Vega-Lite binning documentation

biExtent : Float -> Float -> BinProperty

Specify the desired range of bin values when binning a collection of values. The first and second parameters indicate the minimum and maximum range values respectively. For more details, see the Vega-Lite binning documentation

biMaxBins : Int -> BinProperty

Specify the maximum number of bins when binning a collection of values. For more details, see the Vega-Lite binning documentation

biMinStep : Float -> BinProperty

Specify the step size between bins when binning a collection of values. For more details, see the Vega-Lite binning documentation

biNice : Bool -> BinProperty

Specify whether or not binning boundaries use human-friendly values such as multiples of ten. For more details, see the Vega-Lite binning documentation

biStep : Float -> BinProperty

Specify an exact step size between bins when binning a collection of values. For more details, see the Vega-Lite binning documentation

biSteps : List Float -> BinProperty

Specify the allowable step sizes between bins when binning a collection of values. For more details, see the Vega-Lite binning documentation

Data Calculation

calculateAs : String -> String -> List LabelledSpec -> List LabelledSpec

Creates a new data field based on calculations from existing fields. The first parameter is an expression representing the calculation and the second is the name to give the newly calculated field. This third parameter is a list of any previous calculations to which this is to be added. See the Vega-Lite documentation for further details.

trans =
    transform << calculateAs "datum.sex == 2 ? 'F' : 'M'" "gender"

Filtering

filter : Filter -> List LabelledSpec -> List LabelledSpec

Adds the given filter operation a list of transformations that may be applied to a channel or field. The first parameter is the filter operation and the second, often implicit, parameter is the list of other filter operations to which this should be added in sequence.

trans =
    transform
        << filter (fiEqual "Animal" (str "Cat"))

Filter operations can combine selections and data predicates with BooleanOp expressions:

trans =
    transform
        << filter (fiCompose (and (expr "datum.Weight_in_lbs > 3000") (fiSelection "brush")))
fiEqual : String -> DataValue -> Filter

Filter a data stream so that only data in a given field equal to the given value are used. For details, see the Vega-Lite documentation.

fiExpr : String -> Filter

Filter a data stream so that only data that satisfy the given predicate expression are used. For details, see the Vega-Lite documentation.

fiCompose : BooleanOp -> Filter

Build up a filtering predicate through logical composition (and, or etc.). See the Vega-Lite documentation for details.

fiSelection : String -> Filter

Filter a data stream so that only data in a given field that are within the given interactive selection are used. For details, see the Vega-Lite documentation.

fiOneOf : String -> DataValues -> Filter

Filter a data stream so that only data in a given field contained in the given list of values are used. For details, see the Vega-Lite documentation.

fiRange : String -> FilterRange -> Filter

Filter a data stream so that only data in a given field that are within the given range are used. For details, see the Vega-Lite documentation.

numRange : Float -> Float -> FilterRange

Specify the min max number range to be used in data filtering.

dtRange : List DateTime -> List DateTime -> FilterRange

Specify the min max date-time range to be used in data filtering. If either parameter is an empty list, it is assumed to be unbounded.

Relational Joining (lookup)

String
-> ( VLProperty, Spec )
-> String
-> List String
-> List LabelledSpec
-> List LabelledSpec

Perform a lookup of named fields between two data sources. This allows you to find values in one data source based on the values in another (like a relational join). The first parameter is the field in the primary data source to act as key, the second is the secondary data source which can be specified with a call to dataFromUrl or other data generating function. The third is the name of the field in the secondary data source to match values with the primary key. The fourth parameter is the list of fields to be stored when the keys match. As with other transformation functions, the final implicit parameter is a list of any other transformations to which this is to be added.

Unlike lookupAs, this function will only return the specific fields named in the fourth parameter. If you wish to return the entire set of fields in the secondary data source as a single object, use lookupAs.

See the Vega-Lite documentation for further details.

The following would return the values in the age and height fields from lookup_people.csv for all rows where the value in the name column in that file matches the value of person in the primary data source.

data =
    dataFromUrl "data/lookup_groups.csv" []


trans =
    transform
        << lookup "person" (dataFromUrl "data/lookup_people.csv" []) "name" [ "age", "height" ]
String
-> ( VLProperty, Spec )
-> String
-> String
-> List LabelledSpec
-> List LabelledSpec

Perform an object lookup between two data sources. This allows you to find values in one data source based on the values in another (like a relational join). The first parameter is the field in the primary data source to act as key, the second is the secondary data source which can be specified with a call to dataFromUrl or other data generating function. The third is the name of the field in the secondary data source to match values with the primary key. The fourth parameter is the name to be given to the object storing matched values. As with other transformation functions, the final implicit parameter is a list of any other transformations to which this is to be added.

Unlike lookup, this function returns the entire set of field values from the secondary data source when keys match. Those fields are stored as an object with the name provided in the fourth parameter.

See the Vega-Lite documentation for further details.

In the following example, personDetails would reference all the field values in lookup_people.csv for each row where the value in the name column in that file matches the value of person in the primary data source.

data =
    dataFromUrl "data/lookup_groups.csv" []


trans =
    transform
        << lookupAs "person" (dataFromUrl "data/lookup_people.csv" []) "name" "personDetails"

Window Transformations

String
-> List Window
-> List WindowProperty
-> List LabelledSpec
-> List LabelledSpec

Adds the window transform to a list of transformations that may be applied to a data stream. The window transform performs calculations over sorted groups of data objects. These calculations including ranking, lead/lag analysis, and aggregates such as running sums and averages. Calculated values are written back to the input data stream.

The first parameter is the name to give the transformed output. The second is the window transform field definition. The third the window transform definition.

trans =
    transform
        << windowAs "TotalTime"
            [ wiAggregateOp Sum, wiField "Time" ]
            [ wiFrame Nothing Nothing ]
wiAggregateOp : Operation -> Window

Specify an aggregrate operation as part of a window transformation. A window transformation must specify either one of these aggregate operations or a window-only transformation (wiOp). For details see the Vega-Lite window transform documentation

wiOp : WindowOperation -> Window

Specify an window-specific operation as part of a window transformation. A window transformation must specify either one of these window-only operations or an aggregate transformation (wiAggregateOp). For details see the Vega-Lite window transform documentation

wiParam : Int -> Window

Specify the numeric parameter for those window-only operations that can be parameterised (Ntile, Lag, Lead and NthValue). For details see the Vega-Lite window transform documentation

wiField : String -> Window

Specify an data field for which to compute an operation. This is not needed for operations that do not apply to fields such as Count, Rank and DenseRank. For details see the Vega-Lite window transform documentation

wiFrame : Maybe Int -> Maybe Int -> WindowProperty

Specify a sliding window should be produced for use by a window transform. The two parameters should either be a Just a number indicating the offset from the current data object, or Nothing to indicate unbounded rows preceding or following the current data object. The default value is equivalent to Nothing (Just 0), indicating that the sliding window includes the current object and all preceding objects. The value (Just 5) (Just 5) indicates that the window should include five objects preceding and five objects following the current object. Finally, Nothing Nothing indicates that the window frame should always include all data objects. For details see the Vega-Lite window transform documentation

wiIgnorePeers : Bool -> WindowProperty

Specify whether or not the sliding window frame in a window transform should ignore peer values (those considered identical by the sort criteria). The default is false, causing the window frame to expand to include all peer values. If set to be true, the window frame will be defined by offset values only. For details see the Vega-Lite window transform documentation

wiGroupBy : List String -> WindowProperty

Specify the data fields for partioning data objects in a window transform into separate windows. If unspecified, all points will be in a single group. For details see the Vega-Lite window transform documentation

wiSort : List WindowSortField -> WindowProperty

Specify a comparator for sorting data objects within a window transform. If two data objects are considered equal by the comparator, they are considered peer values of equal rank. If not specified, data objects are processed in the order they are observed and none are considered peers. For details see the Vega-Lite window transform documentation

wiAscending : String -> WindowSortField

Specify that the given field should be sorted in ascending order when performing a window transform. For details, see the Vega-Lite window transform field documentation

wiDescending : String -> WindowSortField

Specify that the given field should be sorted in descending order when performing a window transform. For details, see the Vega-Lite window transform field documentation

type Window

Window transform field definition. For details see the Vega-Lite window transform field documentation

= RowNumber
| Rank
| DenseRank
| PercentRank
| CumeDist
| Ntile
| Lag
| Lead
| FirstValue
| LastValue
| NthValue

Operations that may be applied during a window transformation. For details see the Vega-Lite window operation documentation.

Window transform properties for performing calculations over sorted groups. For details see the Vega-Lite window transform documentation

A named field with either an ascending or descending sort direction. Used by the window transform for performing calculations over sorted groups. For details, see the Vega-Lite window transform field documentation

Creating the Mark Specification

Functions and types for declaring the type of visual marks used in the visualization. The preferred method of specifying mark types is to call the relevant mark function (e.g. bar, line etc.) rather than mark Bar, mark Line etc.

area : List MarkProperty -> ( VLProperty, Spec )

Specify an area mark. An area mark is used for representing a series of data elements, such as in a stacked area chart or streamgraph. For details see the Vega Lite documentation.

area [ maStroke "white" ]

To keep the default style for the mark, just provide an empty list as the parameter.

area []
bar : List MarkProperty -> ( VLProperty, Spec )

Specify an bar mark. Bars are used for histograms, bar charts etc. for showing the magnitude of values in categories. For details see the Vega Lite documentation.

bar [ maFill "black", maStroke "white", maStrokeWeight 2 ]

To keep the default style for the mark, just provide an empty list as the parameter.

bar []
circle : List MarkProperty -> ( VLProperty, Spec )

Specify a circle mark for symbolising points. For details see the Vega Lite documentation.

circle [ maStroke "red", maStrokeWeight 2 ]

To keep the default style for the mark, just provide an empty list as the parameter.

circle []
geoshape : List MarkProperty -> ( VLProperty, Spec )

Specify a an arbitrary shape determined by georaphically referenced coordinates. For details see the Vega Lite documentation.

geoshape [ maFill "blue", maStroke "white" ]
line : List MarkProperty -> ( VLProperty, Spec )

Specify a line mark for symbolising a sequence of values. For details see the Vega Lite documentation.

line [maStroke "red", maStrokeDash [1, 2] ]

To keep the default style for the mark, just provide an empty list as the parameter.

line []
point : List MarkProperty -> ( VLProperty, Spec )

Specify a point mark for symbolising a data point with a symbol. For details see the Vega Lite documentation.

point [ maFill "black", maStroke "red" ]

To keep the default style for the mark, just provide an empty list as the parameter.

point []
rect : List MarkProperty -> ( VLProperty, Spec )

Specify an arbitrary rectangle. For details see the Vega Lite documentation.

rect [ maFill "black", maStroke "red" ]

To keep the default style for the mark, just provide an empty list as the parameter.

rect []
rule : List MarkProperty -> ( VLProperty, Spec )

Specify a line seqment connecting two vertices. Can either be used to span the entire width or height of a view, or to connect two arbitrary positions. For details see the Vega Lite documentation.

rule [ maStroke "red" ]

To keep the default style for the mark, just provide an empty list as the parameter.

rule []
square : List MarkProperty -> ( VLProperty, Spec )

Specify a square mark for symbolising points. For details see the Vega Lite documentation.

square [ maStroke "red", maStrokeWeight 2 ]

To keep the default style for the mark, just provide an empty list as the parameter.

square []
textMark : List MarkProperty -> ( VLProperty, Spec )

Specify a text mark to be displayed at some point location. For details see the Vega Lite documentation.

textMark [ maFontSize 18 ]

To keep the default style for the mark, just provide an empty list as the parameter.

textMark []
tick : List MarkProperty -> ( VLProperty, Spec )

Specify a short line mark for symbolising point locations. For details see the Vega Lite documentation.

tick [ maStroke "blue", maStrokeWeight 0.5 ]

To keep the default style for the mark, just provide an empty list as the parameter.

tick []
trail : List MarkProperty -> ( VLProperty, Spec )

Specify a trail mark. A trail is a line that can vary in thickness along its length. For details see the Vega Lite documentation.

trail [ maInterpolate StepAfter ]

Mark Properties

maAlign : HAlign -> MarkProperty

Specify the horizontal alignment of a text mark. For details see the Vega-Lite text mark property documentation

maAngle : Float -> MarkProperty

Specify the rotation angle in degrees of a text mark. For details see the Vega-Lite text mark property documentation

maBandSize : Float -> MarkProperty

Specify the band size in pixels of a bar mark. For details see the Vega-Lite bar mark property documentation

maBaseline : VAlign -> MarkProperty

Specify the vertical alignment of a text mark. For details see the Vega-Lite text mark property documentation

maBinSpacing : Float -> MarkProperty

Specify the offset between bars for a binned field using a bar mark. For details see the Vega-Lite bar mark property documentation

maClip : Bool -> MarkProperty

Specify whether or not a makr should be clipped to the enclosing group's dimensions. For details see the Vega-Lite mark property documentation

maColor : String -> MarkProperty

Specify the default color of a mark. Note that maFill and maStroke have higher precedence and will override this if specified. For details see the Vega-Lite mark property documentation

maCursor : Cursor -> MarkProperty

Specify the cursor to be associated with a hyperlink mark. For details see the Vega-Lite mark property documentation

maContinuousBandSize : Float -> MarkProperty

Specify the continuous band size in pixels of a bar mark. For details see the Vega-Lite bar mark property documentation

maDiscreteBandSize : Float -> MarkProperty

Specify the discrete band size in pixels of a bar mark. For details see the Vega-Lite bar mark property documentation

maDx : Float -> MarkProperty

Specify the horizontal offset in pixels between a text mark and its anchor. For details see the Vega-Lite text mark property documentation

maDy : Float -> MarkProperty

Specify the vertical offset in pixels between a text mark and its anchor. For details see the Vega-Lite text mark property documentation

maFill : String -> MarkProperty

Specify the default fill color of a mark. For details see the Vega-Lite mark property documentation

maFilled : Bool -> MarkProperty

Specify whether or not a mark's color should be used as the fill color instead of stroke color. For details see the Vega-Lite mark property documentation

maFillOpacity : Float -> MarkProperty

Specify the For details see the Vega-Lite mark property documentation

maFont : String -> MarkProperty

Specify the font of a text mark. This can be any font name made accessible via a css file (or one of the generic fonts serif, monospace etc.). For details see the Vega-Lite text mark property documentation

maFontSize : Float -> MarkProperty

Specify the font size in pixels used by a text mark. For details see the Vega-Lite text mark property documentation

maFontStyle : String -> MarkProperty

Specify the font style (e.g. italic) used by a text mark. For details see the Vega-Lite text mark property documentation

maFontWeight : FontWeight -> MarkProperty

Specify the font wight used by a text mark. For details see the Vega-Lite text mark property documentation

maInterpolate : MarkInterpolation -> MarkProperty

Specify the interpolation method used by line and area marks. For details see the Vega-Lite line mark property documentation

maOpacity : Float -> MarkProperty

Specify the overal opacity of a mark in the range [0, 1]. For details see the Vega-Lite mark property documentation

maOrient : MarkOrientation -> MarkProperty

Specify the orientation of a non-stacked bar, tick, area or line mark. For details see the Vega-Lite line mark property documentation

maPoint : PointMarker -> MarkProperty

Specify the appearance of a point marker placed on the vertices of a line or area mark. For details see the Vega-Lite line mark property documentation

maRadius : Float -> MarkProperty

Specify the polar coordinate radial offset of a text mark from its origin. For details see the Vega-Lite text mark property documentation

maShape : Symbol -> MarkProperty

Specify the shape of a point mark. For details see the Vega-Lite point mark property documentation

maShortTimeLabels : Bool -> MarkProperty

Specify whether or not month and weekday names are abbreviated in a text mark. For details see the Vega-Lite text mark property documentation

maSize : Float -> MarkProperty

Specify the size of a mark. For details see, for example, the Vega-Lite circle mark property documentation

maStroke : String -> MarkProperty

Specify the default stroke color of a mark. For details see the Vega-Lite mark property documentation

maStrokeDash : List Float -> MarkProperty

Specify the stroke dash style used by a mark. A stroke dash style is determined by an alternating 'on-off' sequence of line lengths in pixel units. For details see the Vega-Lite mark property documentation

maStrokeDashOffset : Float -> MarkProperty

Specify the stroke dash offset used by a mark. This is the number of pixels before which the first line dash is drawn. For details see the Vega-Lite mark property documentation

maStrokeOpacity : Float -> MarkProperty

Specify the stroke opacity of a mark in the range [0, 1]. For details see the Vega-Lite mark property documentation

maStrokeWidth : Float -> MarkProperty

Specify the stroke width of a mark in pixel units. For details see the Vega-Lite mark property documentation

maStyle : List String -> MarkProperty

Specify the names of custom styles to apply to the mark. Each name should refer to a named style defined in a separate style configuration. For details see the Vega-Lite mark property documentation

maTension : Float -> MarkProperty

Specify the interpolation tension used if interpolating line and area marks. For details see the Vega-Lite line mark property documentation

maText : String -> MarkProperty

Specify the placeholder text for a text mark for when a text channel is not specified. For details see the Vega-Lite text mark property documentation

maTheta : Float -> MarkProperty

Specify the polar coordinate angle, in radians, of a text mark from the origin determined by its x and y properties. Values for theta follow the same convention of arc mark startAngle and endAngle properties: angles are measured in radians, with 0 indicating “north”. For details see the Vega-Lite text mark property documentation

maThickness : Float -> MarkProperty

Specify the thickness of a tick mark. For details see the Vega-Lite tick mark property documentation

Used by Mark Properties

= Horizontal
| Vertical

Indicates desired orientation of a mark (e.g. horizontally or vertically oriented bars.)

= Basis
| BasisClosed
| BasisOpen
| Bundle
| Cardinal
| CardinalClosed
| CardinalOpen
| Linear
| LinearClosed
| Monotone
| StepAfter
| StepBefore
| Stepwise

Indicates mark interpolation style. See the Vega-Lite documentation for details.

type Symbol
= SymCircle
| SymSquare
| Cross
| Diamond
| TriangleUp
| TriangleDown
| Path String

Identifies the type of symbol.

Note: The use of the Path type constructor is deprecated in favour of the symbolPath function.

symbolPath : String -> Symbol

Specify a custom symbol shape with an SVG path description.

type Cursor
= CAuto
| CDefault
| CNone
| CContextMenu
| CHelp
| CPointer
| CProgress
| CWait
| CCell
| CCrosshair
| CText
| CVerticalText
| CAlias
| CCopy
| CMove
| CNoDrop
| CNotAllowed
| CAllScroll
| CColResize
| CRowResize
| CNResize
| CEResize
| CSResize
| CWResize
| CNEResize
| CNWResize
| CSEResize
| CSWResize
| CEWResize
| CNSResize
| CNESWResize
| CNWSEResize
| CZoomIn
| CZoomOut
| CGrab
| CGrabbing

Represents the type of cursor to display. For an explanation of each type, see the CSS documentation

= PMTransparent
| PMNone

Specify the appearance of a point marker that is overlaid on a line or area mark. For details see the Vega-Lite point property documentation.

pmMarker : List MarkProperty -> PointMarker

Specify the properties of a point marker that is overlaid on a line or area mark. For details see the Vega-Lite point property documentation.

Creating the Encoding Specification

Types and functions for declaring which data fields are mapped to which channels. Channels can include position on screen (e.g. X,Y), visual mark properties (e.g. color, size, stroke, shape), text, hyperlinks, ordering, level of detail and facets (for composed visualizations). All can be further customised via a series of properties for determining how that encoding is implemented (e.g. scaling, sorting, spacing).

encoding : List LabelledSpec -> ( VLProperty, Spec )

Create an encoding specification from a list of channel encodings.

enc =
    encoding
        << position X [ pName "Animal", pMType Ordinal ]
        << position Y [ pName "Age", pMType Quantitative ]
        << shape [ mName "Species", mMType Nominal ]
        << size [ mName "Population", mMType Quantitative ]
= Nominal
| Ordinal
| Quantitative
| Temporal
| GeoFeature

Type of measurement to be associated with some channel. Nominal data are categories identified by name alone and which have no intrinsic order. Ordinal data are also categories, but ones which have some natural order. Quantitative data are numeric measurements typically on a continuous scale. Temporal data describe time.

Geospatial position encoding (Longitude and Latitude) should specify the pMType as Quantitative. Geographically referenced features encoded as shape marks should specify mMType as GeoFeature (Vega-Lite currently refers to this type as geojson).

Position channel

Relates to where something appears in the visualization.

Position
-> List PositionChannel
-> List LabelledSpec
-> List LabelledSpec

Encode a position channel. The first parameter identifies the channel, the second a list of qualifying options. Usually these will include at least the name of the data field associated with it and its measurement type (either the field name directly, or a reference to a row / column repeat field). The final parameter is a list of any previous channels to which this position channel should be added. This is often implicit when chaining a series of encodings using functional composition.

  enc =
      encoding
        << position X [ pName "Animal", pMType Ordinal ]

Encoding by position will generate an axis by default. To prevent the axis from appearing, simply provide an empty list of axis properties to pAxis :

 enc =
     encoding
       << position X [ pName "Animal", pMType Ordinal, pAxis [] ]
= X
| Y
| X2
| Y2
| Longitude
| Latitude
| Longitude2
| Latitude2

Type of position channel, X and Y represent horizontal and vertical axis dimensions on a plane and X2 and Y2 represent secondary axis dimensions where two scales are overlaid in the same space. Geographic positions represented by longitude and latitude values are identified with Longitude, Latitude and their respective secondary equivalents. Such geographic position channels are subject to a map projection before being placed graphically.

Position Channel Properties

pName : String -> PositionChannel

Provide the name of the field used for encoding with a position channel. For details, see the Vega-Lite field documentation

pRepeat : Arrangement -> PositionChannel

Provide the name of the fields from a repeat operator used for encoding with a position channel. For details, see the Vega-Lite field documentation

pMType : Measurement -> PositionChannel

Specify the field type (level of measurement) when encoding with a position channel. For details, see the Vega-Lite type documentation

pBin : List BinProperty -> PositionChannel

Discretizes a series of numeric values into bins when encoding with a position channel. For details, see the Vega-Lite binning documentation

pTimeUnit : TimeUnit -> PositionChannel

Specify the form of time unit aggregation of field values when encoding with a position channel. For details, see the Vega-Lite time unit documentation

pAggregate : Operation -> PositionChannel

Compute some aggregate summaray statistics for a field to be encoded with a position channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

pScale : List ScaleProperty -> PositionChannel

Specify the scaling applied to a field when encoding with a position channel. The scale will transform a field's value into a position along one axis. For details, see the Vega-Lite position field documentation

pAxis : List AxisProperty -> PositionChannel

Specify the axis properties used when encoding with a position channel. For details, see the Vega-Lite position field documentation

pSort : List SortProperty -> PositionChannel

Specify the sort order for field when encoding with a position channel. For details, see the Vega-Lite position field documentation

pStack : StackProperty -> PositionChannel

Specify the type of stacking offset for field when encoding with a position channel. For details, see the Vega-Lite position field documentation

Properties Used by Position Channels

Sorting Properties

= Ascending
| Descending
| ByField String
| ByRepeat Arrangement
| Op Operation

Allow type of sorting to be customised. To sort a field by the aggregated values of another use the soByField or soByRepeat functions rather than their deprecated type constructor equivalents ByField and ByRepeat.

For details see the Vega-Lite sorting documentation.

soByField : String -> Operation -> SortProperty

Specify a sorting by the aggregated summary of a given field using a given aggregation operation. For example, the following sorts the categorical data field variety by the mean age of the data in each variety category.

position Y [ pName "variety"
           , pMType Ordinal
           , pSort [ soByField "age" Mean, Descending ]
           ]

For details see the Vega-Lite sorting documentation.

soByRepeat : Arrangement -> Operation -> SortProperty

Specify a sorting by the aggregated summaries of the given fields (referenced by a repeat iteration) using a given aggregation operation. For details see the Vega-Lite sorting documentation.

soCustom : DataValues -> SortProperty

Provide a custom sort order by listing data values explicitly. This can be used in place of lists of SortProperty. For example,

let
    data =
        dataFromColumns []
            << dataColumn "a" (strs [ "A", "B", "C" ])
            << dataColumn "b" (nums [ 28, 55, 43 ])


    enc =
        encoding
            << position X
                [ pName "a"
                , pMType Ordinal
                , pSort [ soCustom (strs [ "B", "A", "C" ]) ]
                ]
            << position Y [ pName "b", pMType Quantitative ]
in
toVegaLite [ data [], enc [], bar [] ]

Stacking Properties

= StZero
| StNormalize
| StCenter
| NoStack

Describes the type of stacking to apply to a bar chart.

Axis Properties

axDomain : Bool -> AxisProperty

Specify whether or not the axis baseline (domain) should be included as part of an axis. For details see the Vega axis property documentation

axFormat : String -> AxisProperty

Specify the format to apply to labels on an axis. For details see the Vega axis property documentation

axGrid : Bool -> AxisProperty

Specify whether or not grid lones should be included as part of an axis. For details see the Vega axis property documentation

axLabelAngle : Float -> AxisProperty

Specify the rotation angle in degrees of axis labels. For details see the Vega axis property documentation

axLabelOverlap : OverlapStrategy -> AxisProperty

Specify the overlap strategy for labels when they are too large to fit within the space devoted to an axis. For details see the Vega axis property documentation

axLabelPadding : Float -> AxisProperty

Specify the padding in pixels between an axis and its text labels. For details see the Vega axis property documentation

axLabels : Bool -> AxisProperty

Specify whether or not axis labels should be displayed. For details see the Vega axis property documentation

axMaxExtent : Float -> AxisProperty

Specify the maximum extent in pixels that axis ticks and labels should use. This determines a maximum offset value for axis titles. For details see the Vega axis property documentation

axMinExtent : Float -> AxisProperty

Specify the minimum extent in pixels that axis ticks and labels should use. This determines a minimum offset value for axis titles. For details see the Vega axis property documentation

axOffset : Float -> AxisProperty

Specify the offset, in pixels, by which to displace the axis from the edge of the enclosing group or data rectangle. For details see the Vega axis property documentation

axOrient : Side -> AxisProperty

Specify the orientation of an axis relative to the plot it is describing. For details see the Vega axis property documentation

axPosition : Float -> AxisProperty

Specify the anchor position of the axis in pixels. For x-axis with top or bottom orientation, this sets the axis group x coordinate. For y-axis with left or right orientation, this sets the axis group y coordinate. For details see the Vega axis property documentation

axTicks : Bool -> AxisProperty

Specify whether or not an axis should include tick marks. For details see the Vega axis property documentation

axTickCount : Int -> AxisProperty

Specify the desired number of ticks, for axes visualizing quantitative scales. The resulting number may be different so that values are “nice” (multiples of 2, 5, 10) and lie within the underlying scale’s range. For details see the Vega axis property documentation

axTickSize : Float -> AxisProperty

Specify the tick mark size in pixels. For details see the Vega axis property documentation

axTitle : String -> AxisProperty

Specify the title to display as part of an axis. An empty string can be used to prevent a title being displayed. For details see the Vega axis property documentation

axTitleAlign : HAlign -> AxisProperty

Specify the horizontal alignment of an axis title. For details see the Vega axis property documentation

axTitleAngle : Float -> AxisProperty

Specify the angle in degrees of an axis title. For details see the Vega axis property documentation

axTitleMaxLength : Float -> AxisProperty

Specify the maximum length for an axis title for cases where the title is automatically generated from a field’s description. For details see the Vega axis property documentation

axTitlePadding : Float -> AxisProperty

Specify the padding in pixels between a title and axis. For details see the Vega axis property documentation

axValues : List Float -> AxisProperty

Specify the numeric values to appear along an axis. For details see the Vega axis property documentation

axDates : List (List DateTime) -> AxisProperty

Specify the date/times to appear along an axis. For details see the Vega axis property documentation

axZIndex : Int -> AxisProperty

Specify the drawing order of the axis relative to the other chart elements. A value of 1 indicates axis is drawn in front of chart marks, 0 indicates it is drawn behind them. For details see the Vega axis property documentation

Positioning Constants

= ONone
| OParity
| OGreedy

Type of overlap strategy to be applied when there is not space to show all items on an axis. See the Vega-Lite documentation for more details.

type Side
= STop
| SBottom
| SLeft
| SRight

Represents one side of a rectangular space.

type HAlign
= AlignCenter
| AlignLeft
| AlignRight

Indicates the horizontal alignment of some text such as on an axis or legend.

type VAlign
= AlignTop
| AlignMiddle
| AlignBottom

Indicates the vertical alignment of some text that may be attached to a mark.

Mark channels

Relate to the appearance of the visual marks in the visualization such as their color or size.

size : List MarkChannel -> List LabelledSpec -> List LabelledSpec

Encode a size channel. The first parameter is a list of mark channel properties that characterise the way a data field is encoded by size. The second parameter is a list of any previous channels to which this size channel should be added.

size [ mName "Age", mMType Quantitative ] []
color : List MarkChannel -> List LabelledSpec -> List LabelledSpec

Encode a color channel. The first parameter is a list of mark channel properties that characterise the way a data field is encoded by color. The second parameter is a list of any previous channels to which this color channel should be added.

color [ mName "Species", mMType Nominal ] []

Encoding a color channel will generate a legend by default. To stop the legend appearing, just supply an empty list of legend properties to MLegend :

color [ mName "Species", mMType Nominal, mLegend [] ] []
fill : List MarkChannel -> List LabelledSpec -> List LabelledSpec

Encode a fill channel. This acts in a similar way to encoding by color but only affects the interior of closed shapes. The first parameter is a list of mark channel properties that characterise the way a data field is encoded by fill. The second parameter is a list of any previous channels to which this fill channel should be added.

fill [ mName "Species", mMType Nominal ] []

Note that if both fill and color encodings are specified, fill takes precedence.

stroke : List MarkChannel -> List LabelledSpec -> List LabelledSpec

Encode a stroke channel. This acts in a similar way to encoding by color but only affects the exterior boundary of marks. The first parameter is a list of mark channel properties that characterise the way a data field is encoded by stroke. The second parameter is a list of any previous channels to which this stroke channel should be added.

stroke [ mName "Species", mMType Nominal ] []

Note that if both stroke and color encodings are specified, stroke takes precedence.

opacity : List MarkChannel -> List LabelledSpec -> List LabelledSpec

Encode an opacity channel. The first parameter is a list of mark channel properties that characterise the way a data field is encoded by opacity. The second parameter is a list of any previous channels to which this opacity channel should be added.

opacity [ mName "Age", mMType Quantitative ] []
shape : List MarkChannel -> List LabelledSpec -> List LabelledSpec

Encode a shape channel. The first parameter is a list of mark channel properties that characterise the way a data field is encoded by shape. The second parameter is a list of any previous channels to which this shape channel should be added.

shape [ mName "Species", mMType Nominal ] []

Mark Channel Properties

mName : String -> MarkChannel

Provide the name of the field used for encoding with a mark property channel. For details, see the Vega-Lite field documentation

mRepeat : Arrangement -> MarkChannel

Reference in a mark channel to a field name generated by repeat. The parameter identifies whether reference is being made to fields that are to be laid out in columns or in rows.

mMType : Measurement -> MarkChannel

Specify the field type (level of measurement) when encoding with a mark property channel. For details, see the Vega-Lite type documentation

mScale : List ScaleProperty -> MarkChannel

Specify the scaling applied to a field when encoding with a mark property channel. The scale will transform a field's value into a color, shape, size etc. For details, see the Vega-Lite position field documentation

mBin : List BinProperty -> MarkChannel

Discretizes a series of numeric values into bins when encoding with a mark property channel. For details, see the Vega-Lite binning documentation

mTimeUnit : TimeUnit -> MarkChannel

Specify the form of time unit aggregation of field values when encoding with a mark property channel. For details, see the Vega-Lite time unit documentation

mAggregate : Operation -> MarkChannel

Compute some aggregate summaray statistics for a field to be encoded with a mark property channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

mLegend : List LegendProperty -> MarkChannel

Specify the properties of a legend that describes a mark's encoding. To stop a legend from appearing provide an empty list as a parameter.

color [ mName "Animal", mMType Nominal, mLegend [] ]

For details, see the Vega-Lite type documentation

mSelectionCondition : BooleanOp -> List MarkChannel -> List MarkChannel -> MarkChannel

Specify the properties of a mark channel conditional on interactive selection. The first parameter provides the selection to evaluate, the second the encoding to apply if the mark has been selected, the third the encoding if it is not selected.

color
    [ mSelectionCondition (selectionName "myBrush")
        [ mName "Cylinders", mMType Ordinal ]
        [ mStr "grey" ]
    ]

For details, see the Vega-Lite condition documentation

mDataCondition : BooleanOp -> List MarkChannel -> List MarkChannel -> MarkChannel

Specify the properties of a mark channel conditional on some predicate expression. The first parameter provides the expression to evaluate, the second the encoding to apply if the expression is true, the third the encoding if the expression is false.

color
    [ mDataCondition
        (expr "datum.IMDB_Rating === null")
        [ mStr "#ddd" ]
        [ mStr "rgb(76,120,168)" ]
    ]

For details, see the Vega-Lite condition documentation

mPath : String -> MarkChannel

Provide an SVG path string when encoding with a mark property channel. Useful when providing custom shapes.

mNum : Float -> MarkChannel

Provide a literal numeric value when encoding with a mark property channel.

mStr : String -> MarkChannel

Provide a literal string value when encoding with a mark property channel.

mBoo : Bool -> MarkChannel

Provide a literal Boolean value when encoding with a mark property channel.

Mark Legends

leEntryPadding : Float -> LegendProperty

Specify the padding in pixels between legend entries. For more detail see the Vega-Lite legend property documentation.

leFormat : String -> LegendProperty

Specify the formatting pattern for legend labels. For more detail see the Vega-Lite legend property documentation.

leOffset : Float -> LegendProperty

Specify the offset in pixels of a legend from the edge of its enclosing group / data rectangle. For more detail see the Vega-Lite legend property documentation.

leOrient : LegendOrientation -> LegendProperty

Specify the position of a legend in a scene. For more detail see the Vega-Lite legend property documentation.

lePadding : Float -> LegendProperty

Specify the padding in pixels between a legend and axis. For more detail see the Vega-Lite legend property documentation.

leTickCount : Float -> LegendProperty

Specify the number of tick marks in a quantitative legend. For more detail see the Vega-Lite legend property documentation.

leTitle : String -> LegendProperty

Specify the title of a legend. For more detail see the Vega-Lite legend property documentation.

leType : Legend -> LegendProperty

Specify the type of legend (discrete symbols or continuous gradients). For more detail see the Vega-Lite legend property documentation.

leValues : LegendValues -> LegendProperty

Specify the legend values explicitly. For more detail see the Vega-Lite legend property documentation.

leZIndex : Int -> LegendProperty

Specify the drawing order of a legend relative to other chart elements. To place a legend in front of others use a positive integer, or 0 to draw behind. For more detail see the Vega-Lite legend property documentation.

type Legend
= Gradient
| Symbol

Indicates the type of legend to create. Gradient legends are usually used for continuous quantitative data while symbol legends used for categorical data.

= BottomLeft
| BottomRight
| Left
| None
| Right
| TopLeft
| TopRight

Indicates the legend orientation. See the Vega-Lite documentation for more details.

leNums : List Float -> LegendValues

Specify a set of legend numeric values explicitly.

leStrs : List String -> LegendValues

Specify a set of legend strings explicitly.

leDts : List (List DateTime) -> LegendValues

Specify a set of legend date-times explicitly.

Text Channels

Relate to the appearance of the text and tooltip elements of the visualization.

text : List TextChannel -> List LabelledSpec -> List LabelledSpec

Encode a text channel. The first parameter is a list of text channel properties that define the channel. The second parameter is a list of any previous channels to which this channel is to be added. This is usually implicit when chaining a set of encodings together with functional composition. See the Vega-Lite documentation for further details on the text and tooltip channels and Vega-Lite formatting documentation for formatting the appearance of the text.

enc =
    encoding
        << position X [ pName "miles", pMType Quantitative ]
        << position Y [ pName "gas", pMType Quantitative ]
        << text [ tName "miles", tMType Quantitative ]
tooltip : List TextChannel -> List LabelledSpec -> List LabelledSpec

Encode a tooltip channel. The first parameter is a list of text channel properties that define the channel. The second parameter is a list of any previous channels to which this channel is to be added. This is usually implicit when chaining a set of encodings together with functional composition. See the Vega-Lite documentation for further details on the text and tooltip channels and Vega-Lite formatting documentation for formatting the appearance of the text.

  enc =
      encoding
          << position X [ pName "Horsepower", pMType Quantitative ]
          << position Y [ pName "Miles_per_Gallon", pMType Quantitative ]
          << tooltip [ tName "Year", tMType Temporal, tFormat "%Y" ]

To encode multiple tooltip values with a mark, use tooltips

tooltips : List (List TextChannel) -> List LabelledSpec -> List LabelledSpec

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. The second parameter is a list of any previous channels to which this channel is to be added. See the Vega-Lite documentation for further details on the text and tooltip channels and Vega-Lite formatting documentation for formatting the appearance of the text.

  enc =
      encoding
          << position X [ pName "Horsepower", pMType Quantitative ]
          << position Y [ pName "Miles_per_Gallon", pMType Quantitative ]
          << tooltips [ [ tName "Year", tMType Temporal, tFormat "%Y" ]
                      , [ tName "Cylinders", tMType Quantitative ]
                      ]
tName : String -> TextChannel

Provide the name of the field used for encoding with a text channel. For details, see the Vega-Lite field documentation

tRepeat : Arrangement -> TextChannel

Reference in a text channel to a field name generated by repeat. The parameter identifies whether reference is being made to fields that are to be laid out in columns or in rows.

tMType : Measurement -> TextChannel

Specify the field type (level of measurement) when encoding with a text channel. For details, see the Vega-Lite type documentation

tBin : List BinProperty -> TextChannel

Discretizes a series of numeric values into bins when encoding with a text channel. For details, see the Vega-Lite binning documentation

tAggregate : Operation -> TextChannel

Compute some aggregate summaray statistics for a field to be encoded with a text channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

tTimeUnit : TimeUnit -> TextChannel

Specify the form of time unit aggregation of field values when encoding with a text channel. For details, see the Vega-Lite time unit documentation

tSelectionCondition : BooleanOp -> List TextChannel -> List TextChannel -> TextChannel

Specify the properties of a text channel conditional on interactive selection. The first parameter provides the selection to evaluate, the second the encoding to apply if the text has been selected, the third the encoding if it is not selected. For details, see the Vega-Lite condition documentation

tDataCondition : BooleanOp -> List TextChannel -> List TextChannel -> TextChannel

Specify the properties of a text channel conditional on some predicate expression. The first parameter provides the expression to evaluate, the second the encoding to apply if the expression is true, the third the encoding if the expression is false. For details, see the Vega-Lite condition documentation

tFormat : String -> TextChannel

Provide a formatting pattern for a field when encoding with a text channel.

= Bold
| Bolder
| Lighter
| Normal
| W100
| W200
| W300
| W400
| W500
| W600
| W700
| W800
| W900

Indicates the weight options for a font.

Relates to a clickable URL destination of a mark. Note that unlike most other channels, the hyperlink channel has no direct visual expression other than the option of changing the cursor style when hovering, so an encoding will usually pair hyperlinks with other visual channels such as marks or texts.

hName : String -> HyperlinkChannel

Provide the name of the field used for encoding with a hyperlink channel. For details, see the Vega-Lite field documentation

hRepeat : Arrangement -> HyperlinkChannel

Reference in a hyperlink channel to a field name generated by repeat. The parameter identifies whether reference is being made to fields being laid out in columns or in rows.

hMType : Measurement -> HyperlinkChannel

Specify the field type (level of measurement) when encoding with a hyperlink channel. For details, see the Vega-Lite type documentation

hBin : List BinProperty -> HyperlinkChannel

Discretizes a series of numeric values into bins when encoding with a hyperlink channel. For details, see the Vega-Lite binning documentation

hAggregate : Operation -> HyperlinkChannel

Compute some aggregate summaray statistics for a field to be encoded with a hyperlink channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

hTimeUnit : TimeUnit -> HyperlinkChannel

Specify the form of time unit aggregation of field values when encoding with a hyperlink channel. For details, see the Vega-Lite time unit documentation

BooleanOp
-> List HyperlinkChannel
-> List HyperlinkChannel
-> HyperlinkChannel

Specify the properties of a hyperlink channel conditional on some predicate expression. The first parameter provides the expression to evaluate, the second the encoding to apply if the expression is true, the third the encoding if the expression is false. For details, see the Vega-Lite condition documentation

BooleanOp
-> List HyperlinkChannel
-> List HyperlinkChannel
-> HyperlinkChannel

Specify the properties of a hyperlink channel conditional on interactive selection. The first parameter provides the selection to evaluate, the second the encoding to apply if the hyperlink has been selected, the third the encoding if it is not selected. For details, see the Vega-Lite condition documentation

hStr : String -> HyperlinkChannel

Provide a literal string value when encoding with a hyperlink channel.

Order channels

Channels that relate to the order of data fields such as for sorting stacking order or order of data points in a connected scatterplot. See the Vega-Lite documentation for further details.

order : List OrderChannel -> List LabelledSpec -> List LabelledSpec

Encode an order channel. The first parameter is a list of order field definitions to define the channel. The second parameter is a list of any previous channels to which this order channel is to be added.

enc =
    encoding
        << position X [ pName "miles", pMType Quantitative ]
        << position Y [ pName "gas", pMType Quantitative ]
        << order [ oName "year", oMType Temporal ]
oName : String -> OrderChannel

Provide the name of the field used for encoding with an order channel. For details, see the Vega-Lite field documentation

oRepeat : Arrangement -> OrderChannel

Reference in a order channel to a field name generated by repeat. The parameter identifies whether reference is being made to fields that are to be laid out in columns or in rows.

oMType : Measurement -> OrderChannel

Specify the field type (level of measurement) when encoding with an order channel. For details, see the Vega-Lite type documentation

oBin : List BinProperty -> OrderChannel

Discretizes a series of numeric values into bins when encoding with an order channel. For details, see the Vega-Lite binning documentation

oAggregate : Operation -> OrderChannel

Compute some aggregate summaray statistics for a field to be encoded with an order channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

oSort : List SortProperty -> OrderChannel

Specify the sort order to be used by an order channel. Vega-Lite order field documentation

oTimeUnit : TimeUnit -> OrderChannel

Specify the form of time unit aggregation of field values when encoding with an order channel. For details, see the Vega-Lite time unit documentation

Facet channels

Channels for faceting single plots into small multiples. Can be used to create trellis plots or other arrangements in rows and columns. See the Vega-Lite documentation for further details. See also, 'faceted view composition' for a more flexible (but more verbose) way of defining faceted views.

row : List FacetChannel -> List LabelledSpec -> List LabelledSpec

Encode a new facet to be arranged in rows. The first parameter is a list of facet properties that define the faceting channel. This should include at least the name of data the field and its measurement type. The final parameter is a list of any previous channels to which this is to be added. This is usually implicit when chaining encodings using functional composition

enc =
    encoding
        << position X [ pName "people", pMType Quantitative ]
        << position Y [ pName "gender", pMType Nominal ]
        << row [ fName "age", fMType Ordinal ]
column : List FacetChannel -> List LabelledSpec -> List LabelledSpec

Encodes a new facet to be arranged in columns. The first parameter is a list of properties that define the faceting channel. This should include at least the name of the data field and its measurement type. The final parameter is a list of any previous channels to which this is to be added. This is usually implicit when chaining encodings using functional composition

enc =
    encoding
        << position X [ pName "people", pMType Quantitative ]
        << position Y [ pName "gender", pMType Nominal ]
        << column [ fName "age", fMType Ordinal ]

Level of detail Channel

Used for grouping data but without changing the visual appearance of a mark. When, for example, a field is encoded by color, all data items with the same value for that field are given the same color. When a detail channel encodes a field, all data items with the same value are placed in the same group. This allows, for example a line chart with multiple lines to be created – one for each group. See the Vega-Lite documentation for more information.

detail : List DetailChannel -> List LabelledSpec -> List LabelledSpec

Encode a 'level of detail' channel. This provides a way of grouping by a field but unlike, say color, all groups have the same visual properties. The first parameter is a list of the field characteristics to be grouped. The second parameter is a list of any previous channels to which this detail channel should be added. See the Vega-Lite documentation for details.

detail [ dName "Species", dMType Nominal ] []
dName : String -> DetailChannel

Provide the name of the field used for encoding with a level of detail (grouping) channel. For details, see the Vega-Lite field documentation

dMType : Measurement -> DetailChannel

Specify the field type (level of measurement) when encoding with a level of detail (grouping) channel. For details, see the Vega-Lite type documentation

dAggregate : Operation -> DetailChannel

Compute some aggregate summaray statistics for a field to be encoded with a level of detail (grouping) channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

dBin : List BinProperty -> DetailChannel

Discretizes a series of numeric values into bins when encoding with a level of detail (grouping) channel. For details, see the Vega-Lite binning documentation

dTimeUnit : TimeUnit -> DetailChannel

Specify the form of time unit aggregation of field values when encoding with a level of detail (grouping) channel. For details, see the Vega-Lite time unit documentation

Scaling

Used to specify how the encoding of a data field should be applied.

scType : Scale -> ScaleProperty

Specify the type of scaling to apply. For details see the Vega-Lite scale type documentation

scDomain : ScaleDomain -> ScaleProperty

Specify a custom scaling domain. For details see the Vega-Lite scale domain documentation

scRange : ScaleRange -> ScaleProperty

Specify the range of a scaling. The type of range depends on the encoding channel. For details see the Vega-Lite scale range documentation

scScheme : String -> List Float -> ScaleProperty

Specify the color scheme used by a color scaling. For details see the Vega-Lite scale color scheme documentation

scPadding : Float -> ScaleProperty

Specify the padding in pixels to apply to a scaling. For details see the Vega-Lite scale documentation

scPaddingInner : Float -> ScaleProperty

Specify the inner padding in pixels to apply to a band scaling. For details see the Vega-Lite band scale documentation

scPaddingOuter : Float -> ScaleProperty

Specify the outer padding in pixels to apply to a band scaling. For details see the Vega-Lite band scale documentation

scRangeStep : Maybe Float -> ScaleProperty

Specify the distance in pixels between the starts of adjacent bands in a band scaling. If Nothing is provided the distance is determined automatically. For details see the Vega-Lite band scale documentation

scRound : Bool -> ScaleProperty

Specify whether or not numeric values in a scaling are rounded to integers. For details see the Vega-Lite scale documentation

scClamp : Bool -> ScaleProperty

Specify that when scaling, values outside the data domain are clamped to the minimum or maximum value. For details see the Vega-Lite scale documentation

scInterpolate : CInterpolate -> ScaleProperty

Specify an interpolation method for scaling range values. For details see the Vega-Lite scale documentation

scNice : ScaleNice -> ScaleProperty

Specify 'nice' minimum and maximum values in a scaling (e.g. multiples of 10). For details see the Vega-Lite scale documentation

scZero : Bool -> ScaleProperty

Specify whether or not a numeric scaling should be forced to include a zero value. For details see the Vega-Lite scale documentation

scReverse : Bool -> ScaleProperty

Reverse the order of a scaling. For details see the Vega scale documentation

type Scale
= ScLinear
| ScPow
| ScSqrt
| ScLog
| ScTime
| ScUtc
| ScSequential
| ScOrdinal
| ScBand
| ScPoint
| ScBinLinear
| ScBinOrdinal

Used to indicate the type of scale transformation to apply.

raName : String -> ScaleRange

Specify the name of a pre-defined scale range (e.g. symbol or diverging). For details see the Vega-Lite documentation

raNums : List Float -> ScaleRange

Specify a numeric scale range. Depending on the scaling this may be a min,max pair, or a list of explicit numerical values. For details see the Vega-Lite documentation

raStrs : List String -> ScaleRange

Specify a text scale range for discrete scales. For details see the Vega-Lite documentation

categoricalDomainMap : List ( String, String ) -> List ScaleProperty

Create a set of discrete domain to color mappings suitable for customising categorical scales. The first item in each tuple should be a domain value and the second the color value with which it should be associated. It is a convenience function equivalent to specifying separate SDomain and SRange lists and is safer as it guarantees a one-to-one correspondence between domain and range values.

color
    [ mName "weather"
    , mMType Nominal
    , mScale <|
        categoricalDomainMap
            [ ( "sun", "yellow" )
            , ( "rain", "blue" )
            , ( "fog", "grey" )
            ]
    ]
domainRangeMap : ( Float, String ) -> ( Float, String ) -> List ScaleProperty

Create a pair of continuous domain to color mappings suitable for customising ordered scales. The first parameter is a tuple representing the mapping of the lowest numeric value in the domain to its equivalent color; the second tuple the mapping of the highest numeric value to color. If the domain contains any values between these lower and upper bounds they are interpolated according to the scale's interpolation function. This is a convenience function equivalent to specifying separate SDomain and SRange lists and is safer as it guarantees a one-to-one correspondence between domain and range values.

color
    [ mName "year"
    , mMType Ordinal
    , mScale (domainRangeMap ( 1955, "#e6959c" ) ( 2000, "#911a24" ))
    ]
= DNumbers (List Float)
| DStrings (List String)
| DDateTimes (List (List DateTime))
| DSelection String
| Unaggregated

Describes a scale domain (type of data in scale). To specify scale domain values explicitly, use the functions doNums, doStrs, doDts or doSelection rather than their (deprecated) type constructor equivalents.

For full details see the Vega-Lite documentation.

doNums : List Float -> ScaleDomain

Specify the numeric values that define a scale domain. For full details see the Vega-Lite documentation.

doStrs : List String -> ScaleDomain

Specify the string values that define a scale domain. For full details see the Vega-Lite documentation.

doDts : List (List DateTime) -> ScaleDomain

Specify the date-time values that define a scale domain. For full details see the Vega-Lite documentation.

doSelection : String -> ScaleDomain

Specify a scale domain based on a named interactive selection. For full details see the Vega-Lite documentation.

= NMillisecond
| NSecond
| NMinute
| NHour
| NDay
| NWeek
| NMonth
| NYear
| NInterval TimeUnit Int
| IsNice Bool
| NTickCount Int

Describes the way a scale can be rounded to 'nice' numbers. To specify nice time intervals use scNiceInterval rather then the deprecated type constructor NInterval; to switch nice scaling on or off use scIsNice rather than the deprecated type constructor IsNice; and to set a nice tick count use the scNiceTickCount function rather than the deprecated NTickCount type constructor.

For details see the Vega-Lite documentation.

scIsNice : Bool -> ScaleNice

Specify whether or not a scaling should use 'nice' values. For details see Vega-Lite documentation.

scNiceTickCount : Int -> ScaleNice

Specify the desired number of tick marks in a 'nice' scaling. For details see Vega-Lite documentation.

scNiceInterval : TimeUnit -> Int -> ScaleNice

Specify the 'nice' temporal interval values when scaling. For details see Vega-Lite documentation.

Color Scaling

= CubeHelix Float
| CubeHelixLong Float
| Hcl
| HclLong
| Hsl
| HslLong
| Lab
| Rgb Float

Indicates the type of color interpolation to apply, when mapping a data field onto a color scale. Note that color interpolation cannot be applied with the default sequential color scale, so additionally, you should set the sType to another continuous scale such as linear, pow etc.

Several of the interpolation options also require a gamma value (with 1 being a recommended default to provide). These should be generated with the named functions cubeHelix, cubeHelixLong and rgb rather than with a (deprecated) type constructor.

For details see the Vega-Lite documentation.

cubeHelix : Float -> CInterpolate

Specify a cube helix color interpolation for continuous color scales. The parameter is the gamma value to use in interpolation (anchored at 1).

cubeHelixLong : Float -> CInterpolate

Specify a long-path cube helix color interpolation for continuous color scales. The parameter is the gamma value to use in interpolation (anchored at 1).

rgb : Float -> CInterpolate

Specify an RGB color interpolation for continuous color scales. The parameter is the gamma value to use in interpolation (anchored at 1).

Creating view compositions

Views can be combined to create more complex multiview displays. This may involve layering views on top of each other (superposition) or laying them out in adjacent spaces (juxtaposition using repeat, facet, hConcat or vConcat). Where different views have potentially conflicting channels (for example, two position scales in a layered visualization) the rules for resolving them can be defined with resolve. For details of creating composite views see the Vega-Lite documentation

layer : List Spec -> ( VLProperty, Spec )

Assigns a list of specifications to superposed layers in a visualization.

let
    spec1 = ...
    spec2 = ...
in
toVegaLite
    [ dataFromUrl "data/driving.json" []
    , layer [ spec1, spec2 ]
    ]
hConcat : List Spec -> ( VLProperty, Spec )

Assigns a list of specifications to be juxtaposed horizontally in a visualization.

let
    spec1 = ...
    spec2 = ...
in
toVegaLite
    [ dataFromUrl "data/driving.json" []
    , hConcat [ spec1, spec2 ]
    ]
vConcat : List Spec -> ( VLProperty, Spec )

Assigns a list of specifications to be juxtaposed vertically in a visualization.

let
    spec1 = ...
    spec2 = ...
in
toVegaLite
    [ dataFromUrl "data/driving.json" []
    , vConcat [ spec1, spec2 ]
    ]
resolve : List LabelledSpec -> ( VLProperty, Spec )

Determine whether scales, axes or legends in composite views should share channel encodings. This allows, for example, two different color encodings to be created in a layered view, which otherwise by default would share color channels between layers. Each resolution rule should be in a tuple pairing the channel to which it applies and the rule type.

let
    res =
        resolve
            << resolution (reLegend [ ( ChColor, Independent ) ])
in
toVegaLite
    [ dataFromUrl "data/movies.json" []
    , vConcat [ heatSpec, barSpec ]
    , res []
    ]

For more information see the Vega-Lite documentation.

resolution : Resolve -> List LabelledSpec -> List LabelledSpec

Define a single resolution option to be applied when scales, axes or legends in composite views share channel encodings. This allows, for example, two different color encodings to be created in a layered view, which otherwise by default would share color channels between layers. Each resolution rule should be in a tuple pairing the channel to which it applies and the rule type. The first parameter identifies the type of resolution, the second a list of previous resolutions to which this one may be added.

resolve
    << resolution (reScale [ ( ChY, Independent ) ])
reAxis : List ( Channel, Resolution ) -> Resolve

Specify how a channel's axes should be resolved when defined in more than one view in a composite visualization. See the Vega-Lite documentation for details.

reLegend : List ( Channel, Resolution ) -> Resolve

Specify how a channel's legends should be resolved when defined in more than one view in a composite visualization. See the Vega-Lite documentation for details.

reScale : List ( Channel, Resolution ) -> Resolve

Specify how a channel's scales should be resolved when defined in more than one view in a composite visualization. See the Vega-Lite documentation for details.

type Channel
= ChX
| ChY
| ChX2
| ChY2
| ChColor
| ChOpacity
| ChShape
| ChSize

Indicates a channel type to be used in a resolution specification.

= Shared
| Independent

Indicated whether or not a scale domain should be independent of others in a composite visualization. See the Vega-Lite documentation for details.

Faceted views

These are small multiples each of which show subsets of the same dataset. The specification determines which field should be used to determine subsets along with their spatial arrangement (in rows or columns). For details see the Vega-Lite documentation

repeat : List RepeatFields -> ( VLProperty, Spec )

Define the fields that will be used to compose rows and columns of a set of small multiples. This is used where the encoding of the visualization in small multiples is largely identical, but the data field used in each might vary. When a list of fields is identified with repeat you also need to define a full specification to apply to each of those fields using asSpec.

spec = ...
toVegaLite
    [ repeat [ columnFields [ "Cat", "Dog", "Fish" ] ]
    , specification (asSpec spec)
    ]

See the Vega-Lite documentation for further details.

rowFields : List String -> RepeatFields

Create a list of fields to use in set of repeated small multiples arranged in rows. The list of fields named here can be referenced in an encoding with pRepeat Row, mRepeat Row etc.

columnFields : List String -> RepeatFields

Create a list of fields to use in set of repeated small multiples arranged in columns. The list of fields named here can be referenced in an encoding with pRepeat Column, mRepeat Column etc.

facet : List FacetMapping -> ( VLProperty, Spec )

Defines the fields that will be used to facet a view in rows or columns to create a set of small multiples. This is used where the encoding of the visualization in small multiples is identical, but data for each is grouped by the given fields. When creating a faceted view in this way you also need to define a full specification to apply to each of those facets using asSpec.

spec = ...
toVegaLite
    [ facet [ rowBy [ fName "Origin", fMType Nominal ] ]
    , specifcation spec
    ]

See the Vega-Lite documentation for further details.

columnBy : List FacetChannel -> FacetMapping

Specify the mapping between a column and its field definitions in a set of faceted small multiples. For details see the Vega-Lite documentation

rowBy : List FacetChannel -> FacetMapping

Specify the mapping between a row and its field definitions in a set of faceted small multiples. For details see the Vega-Lite documentation

fName : String -> FacetChannel

Provide the name of the field used for encoding with a facet channel. For details, see the Vega-Lite field documentation

fMType : Measurement -> FacetChannel

Specify the field type (level of measurement) when encoding with a facet channel. For details, see the Vega-Lite type documentation

fAggregate : Operation -> FacetChannel

Compute some aggregate summaray statistics for a field to be encoded with a facet channel. The type of aggregation is determined by the given operation parameter. For details, see the Vega-Lite aggregate documentation

fBin : List BinProperty -> FacetChannel

Discretizes a series of numeric values into bins when encoding with a facet channel. For details, see the Vega-Lite binning documentation

fHeader : List HeaderProperty -> FacetChannel

Specify the 'axis' for a series of faceted plots. This is the guide that spans the collection of faceted plots, each of which may have their own axes. For details, see the Vega-Lite facet header documentation

fTimeUnit : TimeUnit -> FacetChannel

Specify the form of time unit aggregation of field values when encoding with a facet channel. For details, see the Vega-Lite time unit documentation

asSpec : List ( VLProperty, Spec ) -> Spec

Create a specification sufficient to define an element in a composed visualization such as a superposed layer or juxtaposed facet. Typically a layer will contain a full set of specifications that define a visualization with the exception of the data specification which is usually defined outside of any one layer. Whereas for repeated and faceted specs, the entire specification is provided.

enc1 = ...
spec1 =
    asSpec [ enc1, line [] ]
specification : Spec -> ( VLProperty, Spec )

Defines a specification object for use with faceted and repeated small multiples.

spec = ...
toVegaLite
    [ facet [ rowBy [ fName "Origin", fMType Nominal ] ]
    , specifcation spec
    ]
= Column
| Row

Identifies whether a repeated/faceted view is arranged in rows or columns.

hdTitle : String -> HeaderProperty

Specify a header title in a faceted view. For details, see the Vega-Lite documentation

hdFormat : String -> HeaderProperty

Header format specifier for a faceted view. For details, see the Vega-Lite documentation

Creating Selections for Interaction

Selections are the way in which interactions (such as clicking or dragging) can be responded to in a visualization. They transform interactions into data queries. For details, see the Vega-Lite documentation.

selection : List LabelledSpec -> ( VLProperty, Spec )

Create a full selection specification from a list of selections. For details see the Vega-Lite documentation.

selection =
    selection << select "view" Interval [ BindScales ]
String
-> Selection
-> List SelectionProperty
-> List LabelledSpec
-> List LabelledSpec

Create a single named selection that may be applied to a data query or transformation. The first two parameters specify the name to be given to the selection for later reference and the type of selection made. The third allows additional selection options to be specified. The fourth is a list of selections to which this is added, which is commonly implicit when chaining a series of selections together with functional composition.

sel =
    selection
        << select "view" Interval [ BindScales ] []
        << select "myBrush" Interval []
        << select "myPaintbrush" Multi [ On "mouseover", Nearest True ]
= Single
| Multi
| Interval

Indicates the type of selection to be generated by the user. Single allows one mark at a time to be selected. 'Multi' allows multiple items to be selected (e.g. with shift-click). 'Interval' allows a bounding rectangle to be dragged by user to select all items intersecting with it.

= Empty
| BindScales
| On String
| Translate String
| Zoom String
| Fields (List String)
| Encodings (List Channel)
| ResolveSelections SelectionResolution
| SelectionMark (List SelectionMarkProperty)
| Bind (List Binding)
| Nearest Bool
| Toggle String

Properties for customising the nature of an interactive selection. See the Vega-Lite documentation for details. For parameterised properties use relevant functions (e.g. seOn, seEncodings, seBind etc.) rather than the (deprecated) type constructors (On, Encodings, Bind etc.).

seBind : List Binding -> SelectionProperty

Specify a binding to some input elements as part of a named selection. For details, see the Vega-Lite bind documentation

seEncodings : List Channel -> SelectionProperty

Specify a encoding channels that form a named selection. For details, see the Vega-Lite selection documentation

seFields : List String -> SelectionProperty

Specify the field names for projecting a selection. For details, see the Vega-Lite projection selection documentation

seNearest : Bool -> SelectionProperty

Specify whether or not a selection should capture nearest marks to a pointer rather than an exact position match. This allows 'accelerated' selection for discrete marks. For details, see the Vega-Lite nearest documentation

seOn : String -> SelectionProperty

Specify a Vega event stream that triggers a selection. For details, see the Vega-Lite selection documentation

seResolve : SelectionResolution -> SelectionProperty

Specify a strategy that determines how selections’ data queries are resolved when applied in a filter transform, conditional encoding rule, or scale domain. For details, see the Vega-Lite selection documentation

seSelectionMark : List SelectionMarkProperty -> SelectionProperty

Specify the appearance of an interval selection mark (dragged rectangle). For details, see the Vega-Lite selection documentation

seToggle : String -> SelectionProperty

Specify a predicate expression that determines a toggled selection. For details, see the Vega-Lite toggle documentation

seTranslate : String -> SelectionProperty

Specify a translation selection transformation used for panning a view. For details, see the Vega-Lite selection translate documentation

seZoom : String -> SelectionProperty

Specify a zooming selection transformation used for zooming a view. For details, see the Vega-Lite selection zoom documentation

iRange : String -> List InputProperty -> Binding

Specify a range slider input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iCheckbox : String -> List InputProperty -> Binding

Specify a checkbox input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iRadio : String -> List InputProperty -> Binding

Specify a radio box input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iSelect : String -> List InputProperty -> Binding

Specify a select input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iText : String -> List InputProperty -> Binding

Specify a text input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iNumber : String -> List InputProperty -> Binding

Specify a number input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iDate : String -> List InputProperty -> Binding

Specify a date input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iTime : String -> List InputProperty -> Binding

Specify a time input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iMonth : String -> List InputProperty -> Binding

Specify a month input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iWeek : String -> List InputProperty -> Binding

Specify a week input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iDateTimeLocal : String -> List InputProperty -> Binding

Specify a local time input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iTel : String -> List InputProperty -> Binding

Specify a telephone number input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

iColor : String -> List InputProperty -> Binding

Specify a color input element that can bound to a named field value (first parameter. For details see the Vega-Lite input element binding documentation and the Vega input binding documentation

inDebounce : Float -> InputProperty

Specify the delay in input event handling when processing input events in order to avoid unnecessary event broadcasting. For details see the Vega-Lite input element documentation

inElement : String -> InputProperty

Specify an optional CSS selector indicating the parent element to which an input element should be added. This allows the option of the input element to be outside the visualization container. For details see the Vega-Lite input element documentation

inOptions : List String -> InputProperty

Specify a range of options for a radio or select input element. For details see the Vega-Lite input element documentation

inMin : Float -> InputProperty

Specify the minimum slider value for a range input element. Defaults to the smaller of the signal value and 0. For details see the Vega-Lite input element documentation

inMax : Float -> InputProperty

Specify the maximum slider value for a range input element. Defaults to the larger of the signal value and 100. For details see the Vega-Lite input element documentation

inName : String -> InputProperty

Specify a custom label for a radio or select input element. For details see the Vega-Lite input element documentation

inStep : Float -> InputProperty

Specify the minimum input element range slider increment. If undefined, the step size will be automatically determined based on the min and max values. For details see the Vega-Lite input element documentation

inPlaceholder : String -> InputProperty

Specify the initial placeholding text for input elements such as text fields. For details see the Vega-Lite input element documentation

= Global
| Union
| Intersection

Determines how selections in faceted or repeated views are resolved. See the Vege-Lite documentation for details

smFill : String -> SelectionMarkProperty

Specify the fill color of the interval selection mark (dragged rectangular area). For details see the Vega-Lite documentation.

smFillOpacity : Float -> SelectionMarkProperty

Specify the fill opacity of the interval selection mark (dragged rectangular area) in the range [0, 1]. For details see the Vega-Lite documentation.

smStroke : String -> SelectionMarkProperty

Specify the stroke color of the interval selection mark (dragged rectangular area). For details see the Vega-Lite documentation.

smStrokeDash : List Float -> SelectionMarkProperty

Specify the stroke dash style of the interval selection mark (dragged rectangular area). For details see the Vega-Lite documentation.

smStrokeDashOffset : Float -> SelectionMarkProperty

Specify the stroke dash offset of the interval selection mark (dragged rectangular area). For details see the Vega-Lite documentation.

smStrokeOpacity : Float -> SelectionMarkProperty

Specify the stroke opacity of the interval selection mark (dragged rectangular area) in the range [0, 1]. For details see the Vega-Lite documentation.

smStrokeWidth : Float -> SelectionMarkProperty

Specify the stroke width of the interval selection mark (dragged rectangular area). For details see the Vega-Lite documentation.

Making conditional channel encodings

Sometimes it is useful to make channel encoding conditional on something. For example, on the result of some interaction such as clicking or dragging or some data property such whether null or an outlier. MSelectionCondition (and TSelectionCondition) will encode a mark (or text) dependent on an interactive selection. MDataCondition (and TDataCondition) will encode it depending on some data property.

For interaction, once a selection has been defined and named, supplying a set of MSelectionCondition encodings allow mark encodings to become dependent on that selection. MSelectionCondition is followed firstly by a Boolean expression relating to the selection upon which it is dependent, then an 'if' and an 'else' clause. Each clause is a list of mark field encodings that should be applied when the selection is true (the 'if clause') and when it is false (the 'else clause'). The color encoding below is saying "whenever data marks are selected with an interval mouse drag, encode the cylinder field with an ordinal color scheme, else make them grey".

  sel =
      selection << select "myBrush" Interval []


  enc =
      encoding
          << position X [ pName "Horsepower", pMType Quantitative ]
          << position Y [ pName "Miles_per_Gallon", pMType Quantitative ]
          << color
              [ mSelectionCondition (selectionName "myBrush")
                  [ mName "Cylinders", mMType Ordinal ]
                  [ mStr "grey" ]
              ]

In a similar way, MDataCondition will encocode a mark in one of two ways depending on whether a predicate test is satisfied.

  enc =
      encoding
          << position X [ pName "IMDB_Rating", pMType Quantitative ]
          << position Y [ pName "Rotten_Tomatoes_Rating", pMType Quantitative ]
            << color
                [ mDataCondition
                    (or (expr "datum.IMDB_Rating === null")
                        (expr "datum.Rotten_Tomatoes_Rating === null")
                    )
                    [ mStr "#ddd" ]
                    [ mStr "#0099ee" ]
                ]

For details, see the Vega-Lite documentation.

and : BooleanOp -> BooleanOp -> BooleanOp

Apply an 'and' Boolean operation as part of a logical composition.

and (expr "datum.IMDB_Rating === null") (expr "datum.Rotten_Tomatoes_Rating === null")
or : BooleanOp -> BooleanOp -> BooleanOp

Apply an 'or' Boolean operation as part of a logical composition.

color
    [ mSelectionCondition (or (selectionName "alex") (selectionName "morgan"))
        [ mAggregate Count, mName "*", mMType Quantitative ]
        [ mStr "gray" ]
    ]
not : BooleanOp -> BooleanOp

Apply a negation Boolean operation as part of a logical composition. Boolean operations can be nested to any level, for example:

not (and (expr "datum.IMDB_Rating === null") (expr "datum.Rotten_Tomatoes_Rating === null") )
expr : String -> BooleanOp

Specify an expression that should evaluate to either true or false. Can use any valid Vega expression.

selected : String -> BooleanOp

Provide an interactive selection that will be true or false as part of a logical composition. For example, to filter a dataset so that only items selected interactively and that have a weight of more than 30:

transform
    << filter (fCompose (and (selected "brush") (expr "datum.weight > 30")))
selectionName : String -> BooleanOp

Provide the name of a selection that is used as part of a conditional encoding.

color
    [ mSelectionCondition (selectionName "myBrush")
        [ mName "Origin", mMType Nominal ]
        [ mStr "grey" ]
    ]

Global Configuration

Configuration options that affect the entire visualization. These are in addition to the data and transform options described above.

name : String -> ( VLProperty, Spec )

Provides an optional name to be associated with the visualization.

enc = ...
toVegaLite
    [ name "PopGrowth"
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
title : String -> ( VLProperty, Spec )

Provide an optional title to be displayed in the visualization.

enc = ...
toVegaLite
    [ title "Population Growth"
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
description : String -> ( VLProperty, Spec )

Provides an optional description to be associated with the visualization.

enc = ...
toVegaLite
    [ description "Population change of key regions since 1900"
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
height : Float -> ( VLProperty, Spec )

Overrides the default height of the visualization. If not specified the height will be calculated based on the content of the visualization.

enc = ...
toVegaLite
    [ height 300
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
width : Float -> ( VLProperty, Spec )

Override the default width of the visualization. If not specified the width will be calculated based on the content of the visualization.

enc = ...
toVegaLite
    [ width 500
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
padding : Padding -> ( VLProperty, Spec )

Set the padding around the visualization in pixel units. The way padding is interpreted will depend on the autosize properties. See the Vega-Lite documentation for details.

enc = ...
toVegaLite
    [ width 500
    , padding (paEdges 20 10 5 15)
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
paSize : Float -> Padding

Specify a uniform padding around a visualization in pixel units.

paEdges : Float -> Float -> Float -> Float -> Padding

Specify padding around a visualization in pixel units. The four parameters refer to left, top, right, and bottom edges respectively.

autosize : List Autosize -> ( VLProperty, Spec )

Declare the way the view is sized. See the Vega-Lite documentation for details.

enc = ...
toVegaLite
    [ width 250
    , height 300
    , autosize [ AFit, APadding, AResize ]
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
background : String -> ( VLProperty, Spec )

Set the background color of the visualization. Should be specified with a CSS string such as #ffe or rgb(200,20,150). If not specified the background will be transparent.

enc = ...
toVegaLite
    [ background "rgb(251,247,238)"
    , dataFromUrl "data/population.json" []
    , bar []
    , enc []
    ]
configure : List LabelledSpec -> ( VLProperty, Spec )

Create a single global configuration from a list of configuration specifications. Configurations are applied to all relevant items in the specification. See the Vega-Lite documentation for more details.

config =
    configure
        << configuration (coAxis [ axcoDomainWidth 1 ])
        << configuration (coView [ vicoStroke Nothing ])
        << configuration (coSelection [ ( Single, [ seOn "dblclick" ] ) ])
configuration : ConfigurationProperty -> List LabelledSpec -> List LabelledSpec

Defines a single configuration option to be applied globally across the visualization. The first parameter identifies the type of configuration, the second a list of previous configurations to which this one may be added.

configuration (coAxis [ axcoDomainWidth 4 ]) []

Style Setting

coArea : List MarkProperty -> ConfigurationProperty

Configure the default appearance of area marks. For details, see the Vega-Lite mark configuration documentation

coAutosize : List Autosize -> ConfigurationProperty

Configure the default sizing of visualizations. For details, see the Vega-Lite top-level configuration documentation

coAxis : List AxisConfig -> ConfigurationProperty

Configure the default appearance of axes. For details, see the Vega-Lite axis configuration documentation

coAxisX : List AxisConfig -> ConfigurationProperty

Configure the default appearance of x-axes. For details, see the Vega-Lite axis configuration documentation

coAxisY : List AxisConfig -> ConfigurationProperty

Configure the default appearance of y-axes. For details, see the Vega-Lite axis configuration documentation

coAxisLeft : List AxisConfig -> ConfigurationProperty

Configure the default appearance of left-side axes. For details, see the Vega-Lite axis configuration documentation

coAxisRight : List AxisConfig -> ConfigurationProperty

Configure the default appearance of right-side axes. For details, see the Vega-Lite axis configuration documentation

coAxisTop : List AxisConfig -> ConfigurationProperty

Configure the default appearance of top-side axes. For details, see the Vega-Lite axis configuration documentation

coAxisBottom : List AxisConfig -> ConfigurationProperty

Configure the default appearance of bottom-side axes. For details, see the Vega-Lite axis configuration documentation

coAxisBand : List AxisConfig -> ConfigurationProperty

Configure the default appearance of axes with band scaling. For details, see the Vega-Lite axis configuration documentation

coBackground : String -> ConfigurationProperty

Configure the default background color of visualizations. For details, see the Vega-Lite top-level configuration documentation

coBar : List MarkProperty -> ConfigurationProperty

Configure the default appearance of bar marks. For details, see the Vega-Lite mark configuration documentation

coCircle : List MarkProperty -> ConfigurationProperty

Configure the default appearance of circle marks. For details, see the Vega-Lite mark configuration documentation

coCountTitle : String -> ConfigurationProperty

Configure the default title style for count fields. For details, see the Vega-Lite top-level configuration documentation

coFieldTitle : FieldTitleProperty -> ConfigurationProperty

Configure the default title generation style for fields. For details, see the Vega-Lite top-level configuration documentation

coGeoshape : List MarkProperty -> ConfigurationProperty

Configure the default appearance of geoshape marks. For details, see the Vega-Lite mark configuration documentation

coLegend : List LegendConfig -> ConfigurationProperty

Configure the default appearance of legends. For details, see the Vega-Lite legend configuration documentation

coLine : List MarkProperty -> ConfigurationProperty

Configure the default appearance of line marks. For details, see the Vega-Lite mark configuration documentation

coMark : List MarkProperty -> ConfigurationProperty

Configure the default mark appearance. For details, see the Vega-Lite mark configuration documentation

coNamedStyle : String -> List MarkProperty -> ConfigurationProperty

Configure the default appearance of a named style. For details, see the Vega-Lite mark style configuration documentation

coNumberFormat : String -> ConfigurationProperty

Configure the default number formatting for axis and text labels. For details, see the Vega-Lite top-level configuration documentation

coPadding : Padding -> ConfigurationProperty

Configure the default padding in pixels from the edge of the of visualization to the data rectangle. For details, see the Vega-Lite top-level configuration documentation

coPoint : List MarkProperty -> ConfigurationProperty

Configure the default appearance of point marks. For details, see the Vega-Lite mark configuration documentation

coProjection : List ProjectionProperty -> ConfigurationProperty

Configure the default style of map projections. For details, see the Vega-Lite projection configuration documentation

coRange : List RangeConfig -> ConfigurationProperty

Configure the default range properties used when scaling. For details, see the Vega-Lite scale range configuration documentation

coRect : List MarkProperty -> ConfigurationProperty

Configure the default appearance of rectangle marks. For details, see the Vega-Lite mark configuration documentation

coRemoveInvalid : Bool -> ConfigurationProperty

Configure the default handling of invalid (null and NaN) values. If true, invalid values are skipped or filtered out when represented as marks. For details, see the Vega-Lite mark configuration documentation

coRule : List MarkProperty -> ConfigurationProperty

Configure the default appearance of rule marks. For details, see the Vega-Lite mark configuration documentation

coScale : List ScaleConfig -> ConfigurationProperty

Configure the default scale properties used when scaling. For details, see the Vega-Lite scale configuration documentation

List ( Selection, List SelectionProperty )
-> ConfigurationProperty

Configure the default appearance of selection marks. For details, see the Vega-Lite documentation

coSquare : List MarkProperty -> ConfigurationProperty

Configure the default appearance of square marks. For details, see the Vega-Lite mark configuration documentation

coStack : StackProperty -> ConfigurationProperty

Configure the default stack offset style for stackable marks. For details, see the Vega-Lite top-level configuration documentation

coText : List MarkProperty -> ConfigurationProperty

Configure the default appearance of text marks. For details, see the Vega-Lite mark configuration documentation

coTick : List MarkProperty -> ConfigurationProperty

Configure the default appearance of tick marks. For details, see the Vega-Lite mark configuration documentation

coTitle : List TitleConfig -> ConfigurationProperty

Configure the default style of visualization titles. For details, see the Vega-Lite title configuration documentation

coTimeFormat : String -> ConfigurationProperty

Configure the default time format for axis and legend labels. For details, see the Vega-Lite top-level configuration documentation

coTrail : List MarkProperty -> List LabelledSpec -> List LabelledSpec

Specify the default style of trail marks.

config =
    configure << coTrail [ maOpacity 0.5, maStrokeDash [ 1, 2 ] ]
coView : List ViewConfig -> ConfigurationProperty

Configure the default single view style. For details, see the Vega-Lite view configuration documentation

= AContent
| AFit
| ANone
| APad
| APadding
| AResize

Indicates the auto-sizing characteristics of the visualization such as amount of padding, whether it should fill the parent container etc. For more details see the Vega-Lite documentation

Axis Configuration Options

axcoBandPosition : Float -> AxisConfig

Specify a default axis band position. For more details, see the Vega-Lite axis config documentation.

axcoDomain : Bool -> AxisConfig

Specify whether or not an axis domain should be displayed by default. For more details, see the Vega-Lite axis config documentation.

axcoDomainColor : String -> AxisConfig

Specify a default axis domain color. For more details, see the Vega-Lite axis config documentation.

axcoDomainWidth : Float -> AxisConfig

Specify a default axis domain width style. For more details, see the Vega-Lite axis config documentation.

axcoMaxExtent : Float -> AxisConfig

Specify a default maximum extent style. For more details, see the Vega-Lite axis config documentation.

axcoMinExtent : Float -> AxisConfig

Specify a default minimum extent style. For more details, see the Vega-Lite axis config documentation.

axcoGrid : Bool -> AxisConfig

Specify whether or not an axis grid is displayed by default. For more details, see the Vega-Lite axis config documentation.

axcoGridColor : String -> AxisConfig

Specify a default axis grid color style. For more details, see the Vega-Lite axis config documentation.

axcoGridDash : List Float -> AxisConfig

Specify a default axis line dash style. For more details, see the Vega-Lite axis config documentation.

axcoGridOpacity : Float -> AxisConfig

Specify a default axis grid line opacity. For more details, see the Vega-Lite axis config documentation.

axcoGridWidth : Float -> AxisConfig

Specify a default axis grid line width. For more details, see the Vega-Lite axis config documentation.

axcoLabels : Bool -> AxisConfig

Specify whether or not an axis has labels by default. For more details, see the Vega-Lite axis config documentation.

axcoLabelAngle : Float -> AxisConfig

Specify a default axis label angle. For more details, see the Vega-Lite axis config documentation.

axcoLabelColor : String -> AxisConfig

Specify a default axis label color. For more details, see the Vega-Lite axis config documentation.

axcoLabelFont : String -> AxisConfig

Specify a default axis label font. For more details, see the Vega-Lite axis config documentation.

axcoLabelFontSize : Float -> AxisConfig

Specify a default axis label font size. For more details, see the Vega-Lite axis config documentation.

axcoLabelLimit : Float -> AxisConfig

Specify a default axis label limit (how much a label can extend beyond the left/bottom or right/top of the axis line). For more details, see the Vega-Lite axis config documentation.

axcoLabelOverlap : OverlapStrategy -> AxisConfig

Specify a default axis label overlap strategy for cases where labels cannot fit within the allotted space. For more details, see the Vega-Lite axis config documentation.

axcoLabelPadding : Float -> AxisConfig

Specify a default axis label padding (space between labels in pixels). For more details, see the Vega-Lite axis config documentation.

axcoShortTimeLabels : Bool -> AxisConfig

Specify whether or not an axis should use short time labels by default. For more details, see the Vega-Lite axis config documentation.

axcoTicks : Bool -> AxisConfig

Specify whether or not an axis should show ticks by default. For more details, see the Vega-Lite axis config documentation.

axcoTickColor : String -> AxisConfig

Specify a default axis tick mark color. For more details, see the Vega-Lite axis config documentation.

axcoTickRound : Bool -> AxisConfig

Specify whether or not axis tick labels use rounded values by default. For more details, see the Vega-Lite axis config documentation.

axcoTickSize : Float -> AxisConfig

Specify a default axis tick mark size in pixel units. For more details, see the Vega-Lite axis config documentation.

axcoTickWidth : Float -> AxisConfig

Specify a default axis tick mark width in pixel units. For more details, see the Vega-Lite axis config documentation.

axcoTitleAlign : HAlign -> AxisConfig

Specify a default axis tick label horizontal alignment. For more details, see the Vega-Lite axis config documentation.

axcoTitleAngle : Float -> AxisConfig

Specify a default axis title angle. For more details, see the Vega-Lite axis config documentation.

axcoTitleBaseline : VAlign -> AxisConfig

Specify a default axis title vertical alignment. For more details, see the Vega-Lite axis config documentation.

axcoTitleColor : String -> AxisConfig

Specify a default axis title color. For more details, see the Vega-Lite axis config documentation.

axcoTitleFont : String -> AxisConfig

Specify a default axis title font. For more details, see the Vega-Lite axis config documentation.

axcoTitleFontWeight : FontWeight -> AxisConfig

Specify a default axis title font weight. For more details, see the Vega-Lite axis config documentation.

axcoTitleFontSize : Float -> AxisConfig

Specify a default axis title font size. For more details, see the Vega-Lite axis config documentation.

axcoTitleLimit : Float -> AxisConfig

Specify a default axis title maximum size. For more details, see the Vega-Lite axis config documentation.

axcoTitleMaxLength : Float -> AxisConfig

Specify a default axis title maximum length when generated automatically from a field's description. For more details, see the Vega-Lite axis config documentation.

axcoTitlePadding : Float -> AxisConfig

Specify a default axis title padding between axis line and text. For more details, see the Vega-Lite axis config documentation.

axcoTitleX : Float -> AxisConfig

Specify a default axis x-position relative to the axis group. For more details, see the Vega-Lite axis config documentation.

axcoTitleY : Float -> AxisConfig

Specify a default axis y-position relative to the axis group. For more details, see the Vega-Lite axis config documentation.

Legend Configuration Options

lecoCornerRadius : Float -> LegendConfig

Specify a default legend corner radius. For more detail see the Vega-Lite documentation.

lecoFillColor : String -> LegendConfig

Specify a default background legend color. For more detail see the Vega-Lite documentation.

lecoOrient : LegendOrientation -> LegendConfig

Specify a default legend position relative to the main plot content. For more detail see the Vega-Lite documentation.

lecoOffset : Float -> LegendConfig

Specify a default offset in pixel units between the legend and the enclosing group or data rectangle. For more detail see the Vega-Lite documentation.

lecoStrokeColor : String -> LegendConfig

Specify a default legend border color. For more detail see the Vega-Lite documentation.

lecoStrokeDash : List Float -> LegendConfig

Specify a default legend border stroke dash style. For more detail see the Vega-Lite documentation.

lecoStrokeWidth : Float -> LegendConfig

Specify a default legend border stroke width. For more detail see the Vega-Lite documentation.

lecoPadding : Float -> LegendConfig

Specify a default spacing in pixel units between a legend and axis. For more detail see the Vega-Lite documentation.

lecoGradientLabelBaseline : VAlign -> LegendConfig

Specify a default vertical alignment for labels in a color ramp legend. For more detail see the Vega-Lite documentation.

lecoGradientLabelLimit : Float -> LegendConfig

Specify a default maximum allowable length for labels in a color ramp legend. For more detail see the Vega-Lite documentation.

lecoGradientLabelOffset : Float -> LegendConfig

Specify a default vertical offset in pixel units for labels in a color ramp legend. For more detail see the Vega-Lite documentation.

lecoGradientStrokeColor : String -> LegendConfig

Specify a default color for strokes in a color ramp legend. For more detail see the Vega-Lite documentation.

lecoGradientStrokeWidth : Float -> LegendConfig

Specify a default width for strokes in a color ramp legend. For more detail see the Vega-Lite documentation.

lecoGradientHeight : Float -> LegendConfig

Specify a default height of a color ramp legend. For more detail see the Vega-Lite documentation.

lecoGradientWidth : Float -> LegendConfig

Specify a default width of a color ramp legend. For more detail see the Vega-Lite documentation.

lecoLabelAlign : HAlign -> LegendConfig

Specify a default horizontal alignment of legend labels. For more detail see the Vega-Lite documentation.

lecoLabelBaseline : VAlign -> LegendConfig

Specify a default vertical alignment of legend labels. For more detail see the Vega-Lite documentation.

lecoLabelColor : String -> LegendConfig

Specify a default color for legend labels. For more detail see the Vega-Lite documentation.

lecoLabelFont : String -> LegendConfig

Specify a default font for legend labels. For more detail see the Vega-Lite documentation.

lecoLabelFontSize : Float -> LegendConfig

Specify a default font size legend labels. For more detail see the Vega-Lite documentation.

lecoLabelLimit : Float -> LegendConfig

Specify a default maximum width for legend labels in pixel units. For more detail see the Vega-Lite documentation.

lecoLabelOffset : Float -> LegendConfig

Specify a default offset for legend labels. For more detail see the Vega-Lite documentation.

lecoShortTimeLabels : Bool -> LegendConfig

Specify whether or not time labels are abbreviated by default in a legend. For more detail see the Vega-Lite documentation.

lecoEntryPadding : Float -> LegendConfig

Specify a default spacing between legend items. For more detail see the Vega-Lite documentation.

lecoSymbolColor : String -> LegendConfig

Specify a default legend symbol color. For more detail see the Vega-Lite documentation.

lecoSymbolType : Symbol -> LegendConfig

Specify a default legend symbol type. For more detail see the Vega-Lite documentation.

lecoSymbolSize : Float -> LegendConfig

Specify a default legend symbol size. For more detail see the Vega-Lite documentation.

lecoSymbolStrokeWidth : Float -> LegendConfig

Specify a default legend symbol stroke width. For more detail see the Vega-Lite documentation.

lecoTitleAlign : HAlign -> LegendConfig

Specify a default horizontal alignment for legend titles. For more detail see the Vega-Lite documentation.

lecoTitleBaseline : VAlign -> LegendConfig

Specify a default vertical alignment for legend titles. For more detail see the Vega-Lite documentation.

lecoTitleColor : String -> LegendConfig

Specify a default color legend titles. For more detail see the Vega-Lite documentation.

lecoTitleFont : String -> LegendConfig

Specify a default font for legend titles. For more detail see the Vega-Lite documentation.

lecoTitleFontSize : Float -> LegendConfig

Specify a default font size for legend titles. For more detail see the Vega-Lite documentation.

lecoTitleFontWeight : FontWeight -> LegendConfig

Specify a default font weight for legend titles. For more detail see the Vega-Lite documentation.

lecoTitleLimit : Float -> LegendConfig

Specify a default maximum size in pixel units for legend titles. For more detail see the Vega-Lite documentation.

lecoTitlePadding : Float -> LegendConfig

Specify a default spacing in pixel units between title and legend. For more detail see the Vega-Lite documentation.

Scale Configuration Options

sacoBandPaddingInner : Float -> ScaleConfig

Specify the default inner padding for x and y band-ordinal scales. For more details see the Vega-Lite scale config documentation

sacoBandPaddingOuter : Float -> ScaleConfig

Specify the default outer padding for x and y band-ordinal scales. For more details see the Vega-Lite scale config documentation

sacoClamp : Bool -> ScaleConfig

Specify whether or not by default values that exceed the data domain are clamped to the min/max range value. For more details see the Vega-Lite scale config documentation

sacoMaxBandSize : Float -> ScaleConfig

Specify the default maximum value for mapping quantitative fields to a bar's size/bandSize. For more details see the Vega-Lite scale config documentation

sacoMinBandSize : Float -> ScaleConfig

Specify the default minimum value for mapping quantitative fields to a bar's size/bandSize. For more details see the Vega-Lite scale config documentation

sacoMaxFontSize : Float -> ScaleConfig

Specify the default maximum value for mapping a quantitative field to a text mark's size. For more details see the Vega-Lite scale config documentation

sacoMinFontSize : Float -> ScaleConfig

Specify the default minimum value for mapping a quantitative field to a text mark's size. For more details see the Vega-Lite scale config documentation

sacoMaxOpacity : Float -> ScaleConfig

Specify the default maximum opacity (in the range [0, 1]) for mapping a field to opacity. For more details see the Vega-Lite scale config documentation

sacoMinOpacity : Float -> ScaleConfig

Specify the default minimum opacity (in the range [0, 1]) for mapping a field to opacity. For more details see the Vega-Lite scale config documentation

sacoMaxSize : Float -> ScaleConfig

Specify the default maximum size for point-based scales. For more details see the Vega-Lite scale config documentation

sacoMinSize : Float -> ScaleConfig

Specify the default minimum size for point-based scales (when not forced to start at zero). For more details see the Vega-Lite scale config documentation

sacoMaxStrokeWidth : Float -> ScaleConfig

Specify the default maximum stroke width for rule, line and trail marks. For more details see the Vega-Lite scale config documentation

sacoMinStrokeWidth : Float -> ScaleConfig

Specify the default minimum stroke width for rule, line and trail marks. For more details see the Vega-Lite scale config documentation

sacoPointPadding : Float -> ScaleConfig

Specify the default padding for point-ordinal scales. For more details see the Vega-Lite scale config documentation

sacoRangeStep : Maybe Float -> ScaleConfig

Specify the default range step for band and point scales when the mark is not text. For more details see the Vega-Lite scale config documentation

sacoRound : Bool -> ScaleConfig

Specify whether or not by default numeric values are rounded to integers when scaling. Useful for snapping to the pixel grid. For more details see the Vega-Lite scale config documentation

sacoTextXRangeStep : Float -> ScaleConfig

Specify the default range step for x band and point scales of text marks. For more details see the Vega-Lite scale config documentation

sacoUseUnaggregatedDomain : Bool -> ScaleConfig

Specify whether or not to use the source data range before aggregation. For more details see the Vega-Lite scale config documentation

Scale Range Configuration Options

racoCategory : String -> RangeConfig

Specify the default color scheme for categorical ranges. For details see the Vega-Lite documentation.

racoDiverging : String -> RangeConfig

Specify the default diverging color scheme. For details see the Vega-Lite documentation.

racoHeatmap : String -> RangeConfig

Specify the default 'heatmap' color scheme. For details see the Vega-Lite documentation.

racoOrdinal : String -> RangeConfig

Specify the default ordinal color scheme. For details see the Vega-Lite documentation.

racoRamp : String -> RangeConfig

Specify the default ramp (contnuous) color scheme. For details see the Vega-Lite documentation.

racoSymbol : String -> RangeConfig

Specify the default color scheme symbols. For details see the Vega-Lite documentation.

Title Configuration Options

ticoAnchor : APosition -> TitleConfig

Specify the default anchor position when placing titles. For further details see the Vega-Lite title config documentation

ticoAngle : Float -> TitleConfig

Specify the default angle when orientating titles. For further details see the Vega-Lite title config documentation

ticoBaseline : VAlign -> TitleConfig

Specify the default vertical alignment when placing titles. For further details see the Vega-Lite title config documentation

ticoColor : String -> TitleConfig

Specify the default color when showing titles. For further details see the Vega-Lite title config documentation

ticoFont : String -> TitleConfig

Specify the default font when showing titles. For further details see the Vega-Lite title config documentation

ticoFontSize : Float -> TitleConfig

Specify the default font size when showing titles. For further details see the Vega-Lite title config documentation

ticoFontWeight : FontWeight -> TitleConfig

Specify the default font weight when showing titles. For further details see the Vega-Lite title config documentation

ticoLimit : Float -> TitleConfig

Specify the default maximim length in pixel units when showing titles. For further details see the Vega-Lite title config documentation

ticoOffset : Float -> TitleConfig

Specify the default offset in pixel units of titles relative to the chart body. For further details see the Vega-Lite title config documentation

ticoOrient : Side -> TitleConfig

Specify the default placement of titles relative to the chart body. For further details see the Vega-Lite title config documentation

View Configuration Options

vicoWidth : Float -> ViewConfig

Specify the default width of single views (e.g. each view in a trellis plot). For further details see the Vega-Lite view config documentation

vicoHeight : Float -> ViewConfig

Specify the default height of single views (e.g. each view in a trellis plot). For further details see the Vega-Lite view config documentation

vicoClip : Bool -> ViewConfig

Specify whether or not by default single views should be clipped. For further details see the Vega-Lite view config documentation

vicoFill : Maybe String -> ViewConfig

Specify the default fill color for single views. For further details see the Vega-Lite view config documentation

vicoFillOpacity : Float -> ViewConfig

Specify the default fill opacity for single views. For further details see the Vega-Lite view config documentation

vicoStroke : Maybe String -> ViewConfig

Specify the default stroke color for single views. If Nothing is provided, no strokes are drawn around the view. For further details see the Vega-Lite view config documentation

vicoStrokeOpacity : Float -> ViewConfig

Specify the default stroke opacity for single views. For further details see the Vega-Lite view config documentation

vicoStrokeWidth : Float -> ViewConfig

Specify the default stroke width of single views. For further details see the Vega-Lite view config documentation

vicoStrokeDash : List Float -> ViewConfig

Specify the default stroke dash style for single views. For further details see the Vega-Lite view config documentation

vicoStrokeDashOffset : Float -> ViewConfig

Specify the default stroke dash offset for single views. For further details see the Vega-Lite view config documentation

= AStart
| AMiddle
| AEnd

Indicates the anchor position for some text.

= Verbal
| Function
| Plain

Indicates the style in which field names are displayed. The Verbal style is 'Sum of field', 'Year of date', 'field (binned)' etc. The Function style is 'SUM(field)', 'YEAR(date)', 'BIN(field)' etc. The Plain style is just the field name without any additional text.

General Data functions

In addition to more general data types like integers and string, the following types can carry data used in specifications.

boo : Bool -> DataValue

Specify a boolean data value. This is used when a function can accept values of different types.

dt : List DateTime -> DataValue

Specify a date-time data value. This is used when a function can accept values of different types.

num : Float -> DataValue

Specify a numeric data value. This is used when a function can accept values of different types.

str : String -> DataValue

Specify a string data value. This is used when a function can accept values of different types.

boos : List Bool -> DataValues

Specify a list of boolean data values. This is used when a function can accept lists of different types.

dts : List (List DateTime) -> DataValues

Specify a list of date-time data values. This is used when a function can accept lists of different types.

nums : List Float -> DataValues

Specify a list of numeric data values. This is used when a function can accept lists of different types.

strs : List String -> DataValues

Specify a string data value. This is used when a function can accept values of different types.

Temporal Data

dtYear : Int -> DateTime

Specify a year as an integer. For details, see the Vega-Lite dateTime documentation

dtQuarter : Int -> DateTime

Specify a year quarter as an integer. For details, see the Vega-Lite dateTime documentation

dtMonth : MonthName -> DateTime

Specify a month as an integer (1=January, 2=February etc.). For details, see the Vega-Lite dateTime documentation

dtDate : Int -> DateTime

Specify a day of the month as an integer. For details, see the Vega-Lite dateTime documentation

dtDay : DayName -> DateTime

Specify a day of the week. For details, see the Vega-Lite dateTime documentation

dtHour : Int -> DateTime

Specify an hour of the day (0=midnight, 1=1am, 23=11pm etc.) an integer. For details, see the Vega-Lite dateTime documentation

dtMinute : Int -> DateTime

Specify a minute of an hour (0-59). For details, see the Vega-Lite dateTime documentation

dtSecond : Int -> DateTime

Specify a second of a minute (0-59). For details, see the Vega-Lite dateTime documentation

dtMillisecond : Int -> DateTime

Specify a millisecond of a second (0-999). For details, see the Vega-Lite dateTime documentation

= Jan
| Feb
| Mar
| Apr
| May
| Jun
| Jul
| Aug
| Sep
| Oct
| Nov
| Dec

Idntifies a month of the year.

type DayName
= Mon
| Tue
| Wed
| Thu
| Fri
| Sat
| Sun

Identifies the day of the week.

= Year
| YearQuarter
| YearQuarterMonth
| YearMonth
| YearMonthDate
| YearMonthDateHours
| YearMonthDateHoursMinutes
| YearMonthDateHoursMinutesSeconds
| Quarter
| QuarterMonth
| Month
| MonthDate
| Date
| Day
| Hours
| HoursMinutes
| HoursMinutesSeconds
| Minutes
| MinutesSeconds
| Seconds
| SecondsMilliseconds
| Milliseconds

Describes a unit of time. Useful for encoding and transformations. See the Vega-Lite documentation for further details.

To encode a time as UTC (coordinated universal time, independent of local time zones or daylight saving), provide a time unit to the utc function. For example,

encoding
    << position X [ pName "date", pMType Temporal, pTimeUnit (utc YearMonthDateHours) ]
utc : TimeUnit -> TimeUnit

Provides a UTC version of a given a time (coordinated universal time, independent of local time zones or daylight saving). For example,

encoding
    << position X [ pName "date", pMType Temporal, pTimeUnit (utc YearMonthDateHours) ]

Deprecated Types and functions

The following are deprecated and will be removed in a future major version release. Generally, the constructors of each type should be replaced with a function of a similar name. For example, instead of the Rule type use the rule function; instead of PAggregate use pAggregate, instead of TmType use tMType etc.

= PName String
| PRepeat Arrangement
| PmType Measurement
| PBin (List BinProperty)
| PTimeUnit TimeUnit
| PAggregate Operation
| PScale (List ScaleProperty)
| PAxis (List AxisProperty)
| PSort (List SortProperty)
| PStack StackProperty

Note: referencing position channel type constructors (PName, PBin etc.) is deprecated in favour of calling their equivalent position channel functions (pName, pBin etc.)

Position channel properties used for creating a position channel encoding.

= MName String
| MRepeat Arrangement
| MmType Measurement
| MScale (List ScaleProperty)
| MBin (List BinProperty)
| MTimeUnit TimeUnit
| MAggregate Operation
| MLegend (List LegendProperty)
| MSelectionCondition
BooleanOp
(List MarkChannel)
(List MarkChannel)
| MDataCondition BooleanOp (List MarkChannel) (List MarkChannel)
| MPath String
| MNumber Float
| MString String
| MBoolean Bool

Note: referencing mark channel type constructors (MName, MBin etc.) is deprecated in favour of calling their equivalent mark channel functions (mName, mBin etc.)

Mark channel properties used for creating a mark channel encoding.

= DName String
| DmType Measurement
| DBin (List BinProperty)
| DTimeUnit TimeUnit
| DAggregate Operation

Note: referencing detail channel type constructors (DName, DBin etc.) is deprecated in favour of calling their equivalent detail channel functions (dName, dBin etc.)

Level of detail channel properties used for creating a grouped channel encoding. For details see the Vega-Lite level of detail channel documentation

= FName String
| FmType Measurement
| FBin (List BinProperty)
| FAggregate Operation
| FTimeUnit TimeUnit
| FHeader (List HeaderProperty)

Note: facet channel type constructors (FName, FBin etc.) are deprecated in favour of calling their equivalent facet channel functions (fName, fBin etc.)

Types of facet channel property used for creating a composed facet view of small multiples.

= HName String
| HRepeat Arrangement
| HmType Measurement
| HBin (List BinProperty)
| HAggregate Operation
| HTimeUnit TimeUnit
| HSelectionCondition
BooleanOp
(List HyperlinkChannel)
(List HyperlinkChannel)
| HDataCondition
BooleanOp
(List HyperlinkChannel)
(List HyperlinkChannel)
| HString String

Note: referencing hyperlink channel type constructors (HName, HBin etc.) is deprecated in favour of calling their equivalent hyperlink channel functions (hName, hBin etc.)

Types of hyperlink channel property used for linking marks or text to URLs.

= OName String
| ORepeat Arrangement
| OmType Measurement
| OBin (List BinProperty)
| OAggregate Operation
| OTimeUnit TimeUnit
| OSort (List SortProperty)

Note: referencing order channel type constructors (OName, OBin etc.) is deprecated in favour of calling their equivalent order channel functions (oName, oBin etc.)

Properties of an ordering channel used for sorting data fields.

= TName String
| TRepeat Arrangement
| TmType Measurement
| TBin (List BinProperty)
| TAggregate Operation
| TTimeUnit TimeUnit
| TSelectionCondition
BooleanOp
(List TextChannel)
(List TextChannel)
| TDataCondition BooleanOp (List TextChannel) (List TextChannel)
| TFormat String

Note: referencing text channel type constructors (TName, TBin etc.) is deprecated in favour of calling their equivalent text channel functions (tName, tBin etc.)

Types of text channel property used for displaying text as part of the visualization.

type Mark
= Area
| Bar
| Circle
| Geoshape
| Line
| Point
| Rect
| Rule
| Square
| Text
| Tick

Note: referencing mark type constructors (mark Area, mark Bar etc.) is deprecated in favour of calling their equivalent mark functions (area, bar etc.)

Type of visual mark used to represent data in the visualization.

mark : Mark -> List MarkProperty -> ( VLProperty, Spec )

Deprecated: Use mark functions (e.g. circle, line) instead.

Create a mark specification. All marks must have a type (first parameter) and can optionally be customised with a list of mark properties such as interpolation style for lines.

= MAlign HAlign
| MAngle Float
| MBandSize Float
| MBaseline VAlign
| MBinSpacing Float
| MClip Bool
| MColor String
| MCursor Cursor
| MContinuousBandSize Float
| MDiscreteBandSize Float
| MdX Float
| MdY Float
| MFill String
| MFilled Bool
| MFillOpacity Float
| MFont String
| MFontSize Float
| MFontStyle String
| MFontWeight FontWeight
| MInterpolate MarkInterpolation
| MOpacity Float
| MOrient MarkOrientation
| MRadius Float
| MShape Symbol
| MShortTimeLabels Bool
| MSize Float
| MStroke String
| MStrokeDash (List Float)
| MStrokeDashOffset Float
| MStrokeOpacity Float
| MStrokeWidth Float
| MStyle (List String)
| MTension Float
| MText String
| MTheta Float
| MThickness Float

Note: referencing mark property type constructors (MAlign, MFill etc.) is deprecated in favour of calling their equivalent mark property functions (maAlign, maFill etc.)

Properties for customising the appearance of a mark. For details see the Vega-Lite documentation.

= Expr String
| Selection String
| SelectionName String
| And BooleanOp BooleanOp
| Or BooleanOp BooleanOp
| Not BooleanOp

Used for creating logical compositions. Note referencing BooleanOp type constructors (And, Not, Expr etc.) is deprecated in favour of calling their equivalent Boolean operation functions (and, not, expr etc.)

bin : List BinProperty -> LabelledSpec

Deprecated in favour of channel-specific binning (e.g. pBin, oBin etc.)

type Binding
= IRange String (List InputProperty)
| ICheckbox String (List InputProperty)
| IRadio String (List InputProperty)
| ISelect String (List InputProperty)
| IText String (List InputProperty)
| INumber String (List InputProperty)
| IDate String (List InputProperty)
| ITime String (List InputProperty)
| IMonth String (List InputProperty)
| IWeek String (List InputProperty)
| IDateTimeLocal String (List InputProperty)
| ITel String (List InputProperty)
| IColor String (List InputProperty)

Note: specifying binding elements with type constructors (IRange, ICheckbox etc.) is deprecated in favour of calling their equivalent input binding functions (iRange, iCheckbox etc.)

Describes the binding property of a selection based on some HTML input element such as a checkbox or radio button. For details see the Vega-Lite documentation and the Vega input binding documentation

= AxDomain Bool
| AxFormat String
| AxGrid Bool
| AxLabelAngle Float
| AxLabelOverlap OverlapStrategy
| AxLabelPadding Float
| AxLabels Bool
| AxMaxExtent Float
| AxMinExtent Float
| AxOffset Float
| AxOrient Side
| AxPosition Float
| AxTicks Bool
| AxTickCount Int
| AxTickSize Float
| AxTitle String
| AxTitleAlign HAlign
| AxTitleAngle Float
| AxTitleMaxLength Float
| AxTitlePadding Float
| AxValues (List Float)
| AxDates (List (List DateTime))
| AxZIndex Int

Note: specifying axis properties with type constructors (AxDomain, AxFormat etc.) is deprecated in favour of calling their equivalent property specifying functions (axDomain, axFormat etc.)

Axis customisation properties. These are used for customising individual axes. To configure all axes, use AxisConfig with a configuration instead. See the Vega-Lite documentation for more details.

= BandPosition Float
| Domain Bool
| DomainColor String
| DomainWidth Float
| MaxExtent Float
| MinExtent Float
| Grid Bool
| GridColor String
| GridDash (List Float)
| GridOpacity Float
| GridWidth Float
| Labels Bool
| LabelAngle Float
| LabelColor String
| LabelFont String
| LabelFontSize Float
| LabelLimit Float
| LabelOverlap OverlapStrategy
| LabelPadding Float
| ShortTimeLabels Bool
| Ticks Bool
| TickColor String
| TickRound Bool
| TickSize Float
| TickWidth Float
| TitleAlign HAlign
| TitleAngle Float
| TitleBaseline VAlign
| TitleColor String
| TitleFont String
| TitleFontWeight FontWeight
| TitleFontSize Float
| TitleLimit Float
| TitleMaxLength Float
| TitlePadding Float
| TitleX Float
| TitleY Float

Note: specifying axis configuration properties with type constructors (BandPosition, Domain, Grid etc.) is deprecated in favour of calling their equivalent property specifying functions (axcoBandPosition, axcoDomain, axcoGrid etc.)

Axis configuration options for customising all axes. See the Vega-Lite documentation for more details.

= Base Float
| Divide Float Float
| Extent Float Float
| MaxBins Int
| MinStep Float
| Nice Bool
| Step Float
| Steps (List Float)

Note: specifying binning properties with type constructors (Base, Extent etc.) is deprecated in favour of calling their equivalent property specifying functions (biBase, biExtent etc.)

Type of binning property to customise. See the Vega-Lite documentation for more details.

= AreaStyle (List MarkProperty)
| Autosize (List Autosize)
| Axis (List AxisConfig)
| AxisX (List AxisConfig)
| AxisY (List AxisConfig)
| AxisLeft (List AxisConfig)
| AxisRight (List AxisConfig)
| AxisTop (List AxisConfig)
| AxisBottom (List AxisConfig)
| AxisBand (List AxisConfig)
| Background String
| BarStyle (List MarkProperty)
| CircleStyle (List MarkProperty)
| CountTitle String
| FieldTitle FieldTitleProperty
| Legend (List LegendConfig)
| LineStyle (List MarkProperty)
| MarkStyle (List MarkProperty)
| NamedStyle String (List MarkProperty)
| NumberFormat String
| Padding Padding
| PointStyle (List MarkProperty)
| Projection (List ProjectionProperty)
| Range (List RangeConfig)
| RectStyle (List MarkProperty)
| RemoveInvalid Bool
| RuleStyle (List MarkProperty)
| Scale (List ScaleConfig)
| SelectionStyle (List ( Selection, List SelectionProperty ))
| SquareStyle (List MarkProperty)
| Stack StackProperty
| TextStyle (List MarkProperty)
| TickStyle (List MarkProperty)
| TitleStyle (List TitleConfig)
| TimeFormat String
| View (List ViewConfig)

Note: referencing configuration properties with type constructors (AreaStyle, Autosize, Axis etc.) is deprecated in favour of calling their equivalent configuration functions (coArea, coAutosize, coAxis etc.).

Type of configuration property to customise. See the Vega-Lite documentation for details.

= Debounce Float
| Element String
| InOptions (List String)
| InMin Float
| InMax Float
| InName String
| InStep Float
| InPlaceholder String

Note: specifying input properties with type constructors (InMin, InOptions etc.) is deprecated in favour of calling their equivalent property specifying functions (inMin, inOptions etc.)

GUI Input properties. The type of relevant property will depend on the type of input element selected. For example an InRange (slider) can have numeric min, max and step values; InSelect (selector) has a list of selection label options. For details see the Vega input element binding documentation.

= HFormat String
| HTitle String

Note: referencing header property type constructors (HFormat and HTitle) is deprecated in favour of calling their equivalent header property functions (hdFormat, hdTitle etc.)

Represents a facet header property. For details, see the Vega-Lite documentation

= CornerRadius Float
| FillColor String
| Orient LegendOrientation
| Offset Float
| StrokeColor String
| LeStrokeDash (List Float)
| LeStrokeWidth Float
| LePadding Float
| GradientLabelBaseline VAlign
| GradientLabelLimit Float
| GradientLabelOffset Float
| GradientStrokeColor String
| GradientStrokeWidth Float
| GradientHeight Float
| GradientWidth Float
| LeLabelAlign HAlign
| LeLabelBaseline VAlign
| LeLabelColor String
| LeLabelFont String
| LeLabelFontSize Float
| LeLabelLimit Float
| LeLabelOffset Float
| LeShortTimeLabels Bool
| EntryPadding Float
| SymbolColor String
| SymbolType Symbol
| SymbolSize Float
| SymbolStrokeWidth Float
| LeTitleAlign HAlign
| LeTitleBaseline VAlign
| LeTitleColor String
| LeTitleFont String
| LeTitleFontSize Float
| LeTitleFontWeight FontWeight
| LeTitleLimit Float
| LeTitlePadding Float

Note: specifying legend configuration properties with type constructors (CornerRadius, FillColor, LePadding etc.) is deprecated in favour of calling their equivalent property specifying functions (lecoCornerRadius, lecoFillColor, lecoPadding etc.)

Legend configuration options. For more detail see the Vega-Lite documentation.

= LEntryPadding Float
| LFormat String
| LOffset Float
| LOrient LegendOrientation
| LPadding Float
| LTickCount Float
| LTitle String
| LType Legend
| LValues LegendValues
| LZIndex Int

Note: referencing legend property type constructors (LFormat, lTitleetc.) is deprecated in favour of calling their equivalent legend property functions (leFormat,leTitle` etc.)

Legend properties for customising a mark legend. For more detail see the Vega-Lite documentation.

= LDateTimes (List (List DateTime))
| LNumbers (List Float)
| LStrings (List String)

Note: referencing legend value type constructors (LNumbers, LStrings and LDateTimes) is deprecated in favour of calling their equivalent legend value functions (leNums, leStrs and leDts)

A list of data values suitable for setting legend values.

= PType Projection
| PClipAngle (Maybe Float)
| PClipExtent ClipRect
| PCenter Float Float
| PRotate Float Float Float
| PPrecision Float
| PCoefficient Float
| PDistance Float
| PFraction Float
| PLobes Int
| PParallel Float
| PRadius Float
| PRatio Float
| PSpacing Float
| PTilt Float

Note: specifying projection properties with type constructors (PType, PClipAngle etc.) is deprecated in favour of calling their equivalent projection property functions (prType, prClipAngle etc.)

Properties for customising a geospatial projection that converts longitude/latitude pairs into planar (x,y) coordinate pairs for rendering and query. For details see the Vega-Lite documentation.

= SType Scale
| SDomain ScaleDomain
| SRange ScaleRange
| SScheme String (List Float)
| SPadding Float
| SPaddingInner Float
| SPaddingOuter Float
| SRangeStep (Maybe Float)
| SRound Bool
| SClamp Bool
| SInterpolate CInterpolate
| SNice ScaleNice
| SZero Bool
| SReverse Bool

Note: specifying scale properties with type constructors (SDomain, SRange etc.) is deprecated in favour of calling their equivalent property specifying functions (scDomain, scRange etc.)

Individual scale property. These are used to customise an individual scale transformation. To customise all scales use config and supply relevant ScaleConfig values. For more details see the Vega-Lite documentation

= SCBandPaddingInner Float
| SCBandPaddingOuter Float
| SCClamp Bool
| SCMaxBandSize Float
| SCMinBandSize Float
| SCMaxFontSize Float
| SCMinFontSize Float
| SCMaxOpacity Float
| SCMinOpacity Float
| SCMaxSize Float
| SCMinSize Float
| SCMaxStrokeWidth Float
| SCMinStrokeWidth Float
| SCPointPadding Float
| SCRangeStep (Maybe Float)
| SCRound Bool
| SCTextXRangeStep Float
| SCUseUnaggregatedDomain Bool

Note: specifying scale configuration properties with type constructors (SCBandPaddingInner, SCClamp, etc.) is deprecated in favour of calling their equivalent property specifying functions (socoBandPaddingInner,sacoClamp, etc.)

Scale configuration property. These are used to configure all scales. For more details see the Vega-Lite documentation

= RCategory String
| RDiverging String
| RHeatmap String
| ROrdinal String
| RRamp String
| RSymbol String

Note: specifying range configuration properties with type constructors (RCategory, RDiverging, etc.) is deprecated in favour of calling their equivalent property specifying functions (racoCategory,racoDiverging, etc.)

Properties for customising the colors of a range. The parameter should be a named color scheme such as accent or purpleorange-11. For details see the Vega-Lite documentation.

= SMFill String
| SMFillOpacity Float
| SMStroke String
| SMStrokeOpacity Float
| SMStrokeWidth Float
| SMStrokeDash (List Float)
| SMStrokeDashOffset Float

Note: specifying selection mark properties with type constructors (SMFill, SMStroke etc.) is deprecated in favour of calling their equivalent functions (smFill, smStroke etc.)

Properties for customising the appearance of an interval selection mark (dragged rectangle). For details see the Vega-Lite documentation.

= TAnchor APosition
| TAngle Float
| TBaseline VAlign
| TColor String
| TFont String
| TFontSize Float
| TFontWeight FontWeight
| TLimit Float
| TOffset Float
| TOrient Side

Note: specifying title configuration properties with type constructors (TAnchor, TAngle, etc.) is deprecated in favour of calling their equivalent property specifying functions (ticoAnchor,ticoAngle, etc.)

Title configuration properties. These are used to configure the default style of all titles within a visualization. For further details see the Vega-Lite documentation

= ViewWidth Float
| ViewHeight Float
| Clip Bool
| Fill (Maybe String)
| FillOpacity Float
| Stroke (Maybe String)
| StrokeOpacity Float
| StrokeWidth Float
| StrokeDash (List Float)
| StrokeDashOffset Float

Note: specifying view configuration properties with type constructors (Clip, ViewWidth, ViewHeight etc.) is deprecated in favour of calling their equivalent property specifying functions (vicoClip,vicoWidth, vicoHeight etc.)

View configuration property. These are used to configure the style of a single view within a visualization such as its size and default fill and stroke colors. For further details see the Vega-Lite documentation

= Boolean Bool
| DateTime (List DateTime)
| Number Float
| Str String

Note: referencing data types with type constructors (Boolean, DateTime, Number and Str) is deprecated in favour of calling their equivalent data value functions (boo, dt, num and str).

A single data value. This is used when a function can accept values of different types (e.g. either a number or a string).

= Booleans (List Bool)
| DateTimes (List (List DateTime))
| Numbers (List Float)
| Strings (List String)

Note: referencing lists of data types with type constructors (Booleans, DateTimes, Numbers and Strings) is deprecated in favour of calling their equivalent data value list functions (boos, dts, nums and strs).

A list of data values. This is used when a function can accept lists of different types (e.g. either a list of numbers or a list of strings).

= DTYear Int
| DTQuarter Int
| DTMonth MonthName
| DTDate Int
| DTDay DayName
| DTHours Int
| DTMinutes Int
| DTSeconds Int
| DTMilliseconds Int

Note: referencing dateTime type constructors (DTYear, DTHours etc.) is deprecated in favour of calling their equivalent dateTime functions (dtYear, dtHour etc.)

Allows a date or time to be represented. This is typically part of a list of functions that each generate a DateTime item to provide a specific point in time. For details see the Vega-Lite documentation.

= GeoPoint Float Float
| GeoPoints (List ( Float, Float ))
| GeoLine (List ( Float, Float ))
| GeoLines (List (List ( Float, Float )))
| GeoPolygon (List (List ( Float, Float )))
| GeoPolygons (List (List (List ( Float, Float ))))

Note: referencing geometry type constructors (GeoPoint, GeoLine etc.) is deprecated in favour of calling their equivalent geometry functions (geoPoint, geoLine etc.)

Specifies the type and content of geometry specifications for programmatically creating GeoShapes. These can be mapped to the GeoJson geometry object types where the pluralised type names refer to their Multi prefixed equivalent in the GeoJSON specification.

= ColumnBy (List FacetChannel)
| RowBy (List FacetChannel)

Note: facet mapping type constructors (ColumnBy and RowBy ) are deprecated in favour of calling their equivalent facet mapping functions (columnBy and rowBy)

Provides details of the mapping between a row or column and its field definitions in a set of faceted small multiples. For details see the Vega-Lite documentation

= RowFields (List String)
| ColumnFields (List String)

Note: specifying repeat fields with type constructors (RowFields and ColumnFields ) is deprecated in favour of calling their equivalent functions (rowFields, columnFields)

Create a list of fields to use in set of repeated small multiples. The list of fields named here can be referenced in an encoding with pRepeat Column, pRepeat Row etc.

type Filter
= FEqual String DataValue
| FExpr String
| FCompose BooleanOp
| FSelection String
| FOneOf String DataValues
| FRange String FilterRange

Note: referencing filter type constructors (FEqual, FExpr etc.) is deprecated in favour of calling their equivalent filtering functions (fiEqual, fiExpr etc.)

Type of filtering operation. See the Vega-Lite documentation for details.

= NumberRange Float Float
| DateRange (List DateTime) (List DateTime)

Note: referencing filter range type constructors (NumberRange and DateRange) is deprecated in favour of calling their equivalent filtering range functions (numRange and dtRange.)

A pair of filter range data values. The first argument is the inclusive minimum vale to accept and the second the inclusive maximum.

type Resolve
= RAxis (List ( Channel, Resolution ))
| RLegend (List ( Channel, Resolution ))
| RScale (List ( Channel, Resolution ))

Note: specifying resolve items with type constructors (RAxis, RLegend and RScale) is deprecated in favour of calling their equivalent resolve functions (reAxis, reLegend and reScale)

Used to determine how a channel's axis, scale or legend domains should be resolved if defined in more than one view in a composite visualization. See the Vega-Lite documentation for details.

type Padding
= PSize Float
| PEdges Float Float Float Float

Note: referencing padding type constructors (PSize and PEdges) is deprecated in favour of calling their equivalent padding functions (paSize and paEdges)

Represents padding dimensions in pixel units. PSize will set the same value on all four edges of a rectangular container while PEdges can be used to specify different sizes on each edge in order left, top, right, bottom.

= RNumbers (List Float)
| RStrings (List String)
| RName String

Note: specifying scale ranges with type constructors (RNumbers, RStrings and RName) is deprecated in favour of calling their equivalent functions (raNums, raStrs and raName.)

Describes a scale range of scale output values. For details see the Vega-Lite documentation.