Create Vega-Lite specifications in Elm. A specification can be sent to a
Vega-Lite runtime to generate the graphics. While this is a pure Elm package, to
generate the graphical output you probably want to send the JSON generated by
toVegaLite via a port to some JavaScript that invokes the Vega-Lite runtime.
Alternatively, to avoid coding the link to the Vega-Lite runtime, you can embed
specifications directly in a litvis document.
Top-level Vega-Lite properties. These are the ones that define the core of the
visualization grammar. All VLProperties are created by functions in 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 specify 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 clicking, dragging and other interactions 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.
Part or all of Vega-Lite specification. Specs are usually nested and can range from a single Boolean value up to the entire Vega-Lite specification.
A named Vega-Lite specification, usually generated by an elm-vega
function. You shouldn't need to create LabelledSpec tuples directly, but are
useful for type annotations.
Combines a list of labelled specifications that may be passed to JavaScript for rendering. Useful when you wish to create a single page with multiple visualizations.
combineSpecs
[ ( "vis1", myFirstVis )
, ( "vis2", mySecondVis )
, ( "vis3", myOtherVis )
]Functions and types for declaring the data to the visualized. See the Vega-Lite documentation.
Declare a data source from a url. The URL can be a local path on a web server or an external (CORS) URL. A list of field formatting instructions can be provided as the second parameter or an empty list to use the default formatting.
Declare a data source from a list of column values. Each column should contain values of the same type, but columns each with a different type are permitted. If columns do not contain the same number of items the dataset will be truncated to the length of the shortest. A list of field formatting instructions can be provided as the first parameter or an empty list to use the default formatting. The columns 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" ])For more complex inline data tables, such as mixtures of arrays and objects, consider using dataFromJson.
Declare a data source from a list of row values. Each row should contain a list of tuples in the form (column name, value). Each column can have a value of a different type but you must ensure that values are of the same type as others in the same column. A list of field formatting instructions can be provided as the first parameter or an empty list to use the default formatting. Rows are most easily generated with dataRow.
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" ) ]Generally, adding data by column is more efficient and less error-prone. For more complex inline data tables, such as mixtures of arrays and objects, consider using dataFromJson.
Declare a data source from a json specification. The most likely use-case is
creating geojson objects with geometry,
geometryCollection and geoFeatureCollection.
For more general cases of json creation such as data tables that mix arrays and
objects, 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 []
]Declare data from a named source. The source may be from named datasets within
a specification or one created via the Vega View API.
A list of field formatting instructions can be provided as the second parameter
or an empty list to use the default formatting.
data = ...
json = ...
enc = ...
toVegaLite
[ datasets [ ( "myData", data [] ), ( "myJson", dataFromJson json [] ) ]
, dataFromSource "myData" []
, bar []
, enc []
]Name to give a data source. Useful when a specification needs to reference a data source, such as one generated via an API call.
data =
dataFromUrl "myData.json" [] |> dataName "myName"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 ) ]
, [ ( "cat", JE.string "b" ), ( "val", JE.float 180 ) ]
]
enc = ...
in
toVegaLite
[ datasets [ ( "myData", data [] ), ( "myJson", dataFromJson json [] ) ]
, dataFromSource "myData" []
, bar []
, enc []
]Create a column of data. A column has a name and a list of values.
Create a row of data. A row comprises a list of (columnName, value) pairs.
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 ])A single column of data. Used when generating inline data with dataColumn.
Geometric object to be used in a geoshape. 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 ) ] ]) []Geo features to be used in a geoshape specification. Each feature object in
this collection can be created with geometry.
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" ) ]
]Geometry objects to be used in a geoshape specification. Each geometry
object can be created with geometry.
geojson =
geometryCollection
[ geometry (geoPolygon [ [ ( -3, 59 ), ( 4, 59 ), ( 4, 52 ), ( -3, 59 ) ] ]) []
, geometry (geoPoint -3.5 55.5) []
]Point geometry for programmatically creating GeoShapes. Equivalent to
the GeoJson geometry point type.
Multi-point geometry for programmatically creating GeoShapes. Equivalent
to the GeoJson geometry multi-point type.
Line geometry for programmatically creating GeoShapes. Equivalent to the
GeoJson geometry line type.
Multi-line geometry for programmatically creating GeoShapes. Equivalent
to the GeoJson geometry multi-line type.
Polygon geometry for programmatically creating GeoShapes. Equivalent
to the GeoJson geometry polygon type.
Multi-polygon geometry for programmatically creating GeoShapes. Equivalent
to the GeoJson geometry multi-polygon type.
Property to be extracted from some JSON when it has some surrounding structure.
e.g., specifying the property values.features is equivalent to retrieving
json.values.features from a JSON object with a custom delimiter.
A topoJSON feature format containing an object with the given name.
A topoJSON mesh format containing an object with the given name. Unlike
topojsonFeature, the corresponding geo data are returned as a single unified mesh,
not as individual GeoJSON features.
Parsing rules when processing some data text, specified as a list of tuples in the form (fieldname, datatype). If an empty list is provided, type inference is based on the data.
Date format for parsing input data using D3's formatting specifiers or left as an empty string for default formatting.
Transformation rules are applied to data fields or geospatial coordinates before they are encoded visually.
Create a single transform from a list of transformation specifications. The order of transformations can be important, e.g. labels created with calculateAs, timeUnitAs and binAs that 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 projection used for geospatial coordinates.
Type of global map projection.
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.
Projection’s viewport clip extent to the specified bounds in pixels.
Projection’s center as longitude and latitude in degrees.
Projection’s three-axis rotation angle. This should be in order lambda phi gamma specifying the rotation angles in degrees about each spherical axis.
Threshold for the projection’s adaptive resampling in pixels. Corresponds to the Douglas–Peucker distance. If precision is not specified, the projection’s current resampling precision of 0.707 is used.
'Hammer' map projection coefficient.
'Satellite' map projection distance.
Bottomley map projection fraction.
Number of lobes in lobed map projections such as the 'Berghaus star'.
Parallel for map projections such as the 'Armadillo'.
Radius value for map projections such as the 'Gingery'.
Ratio value for map projections such as the 'Hill'.
Spacing value for map projections such as the 'Lagrange'.
'Satellite' map projection tilt.
An Albers map projection.
An Albers USA map projection that combines continental USA with Alaska and Hawaii.
An azimuthal equal area map projection.
An azimuthal equidistant map projection.
A conformal conic map projection.
An equal area conic map projection.
An equidistant conic map projection.
An equirectangular (default) map projection that maps longitude to x and latitude to y.
A gnomonic map projection.
A Mercator map projection.
An orthographic map projection.
A stereographic map projection.
A transverse Mercator map projection.
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").
Clipping rectangle in pixel units. The four parameters are respectively 'left', 'top', 'right' and 'bottom' of the rectangular clipping bounds.
See the Vega-Lite aggregate documentation.
Aggregation transformations to be used when encoding channels. Useful when for applying the same transformation to a number of channels without defining it each time. The first parameter is a list of the named aggregation operations to apply. The second is a list of 'group by' fields.
trans =
transform
<< aggregate
[ opAs opMin "people" "lowerBound", opAs opMax "people" "upperBound" ]
[ "age" ]Aggregation operation. The first parameter is the 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.
trans =
transform
<< aggregate
[ opAs opMin "people" "lowerBound"
, opAs opMax "people" "upperBound"
]
[ "age" ]If the operation is Count, it does not apply to any specific field, so the second
parameter can be an empty string.
Create 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.
An input data object containing the maximum field value to be used in an aggregation operation.
An input data object containing the minimum field value to be used in an aggregation operation.
Count of distinct data objects to be used in an aggregation operation.
Sample standard deviation of field values to be used in an aggregation operation.
Population standard deviation of field values to be used in an aggregation operation.
Count of values that are not null, undefined or NaN to be used in an
aggregation operation.
Sample variance of field value to be used in an aggregation operation.
Population variance of field value to be used in an aggregation operation.
See the Vega-Lite binning documentation.
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.
trans =
transform
<< binAs [ biMaxBins 3 ] "IMDB_Rating" "ratingGroup"Note that usually, direct binning within an encoding is preferred over this form of bin transformation.
Number base to use for automatic bin determination (default is base 10).
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.
Desired range of bin values when binning a collection of values. The first and second parameters indicate the minimum and maximum range values.
Maximum number of bins when binning a collection of values.
Step size between bins when binning a collection of values.
Whether or not binning boundaries use human-friendly values such as multiples of ten.
Step size between bins when binning a collection of values.
Allowable step sizes between bins when binning a collection of values.
See the Vega-Lite stack documentation
Apply a stack transform for positioning multiple values. This is an alternative to specifying stacking directly when encoding position. First parameter is the field to be stacked; the second the fields to group by; the third and fourth are the names to give the output field names; the fifth lists the optional offset and sort properties.
Stack offset when applying a stack transformation.
Rescale a stacked layout to use a common height while preserving relative size of stacked quantities.
Offset a stacked layout using a central stack baseline.
Offset a stacked layout using a baseline at the foot of a stack.
Do not stack marks (produces a layed plot).
Ordering within a stack when applying a stack transformation.
Indicate that the given field should be sorted in ascending order.
Indicate that the given field should be sorted in descending order.
Generate 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.
trans =
transform << calculateAs "datum.sex == 2 ? 'F' : 'M'" "gender"See the Vega-Lite filter documentation.
Filter a data stream so that only data in a given field equal to the given value are used.
Filter a data stream so that only data in a given field less than the given value are used.
Filter a data stream so that only data in a given field less than or equal to the given value are used.
Filter a data stream so that only data in a given field greater than the given value are used.
Filter a data stream so that only data in a given field greater than or equal to the given value are used.
Filter a data stream so that only data that satisfy the given predicate expression are used.
Build up a filtering predicate through logical composition (and, or etc.).
Filter a data stream so that only data in a given field that are within the given interactive selection are used.
Filter a data stream so that only data in a given field contained in the given list of values are used.
Filter a data stream so that only data in a given field that are within the given range are used.
Filter a data stream so that only valid data (i.e. not null or NaN) in a given field are used.
Minimum-maximum number range to be used in data filtering.
Min max date-time range to be used in data filtering. If either parameter is an empty list, it is assumed to be unbounded.
Map array-valued fields to a set of individual data objects, one per array entry.
Similar to flatten but allows the new output fields to be named (second parameter).
Collapse one or more data fields into two properties: a key (containing the original data field name) and a value (containing the data value). Useful for mapping matrix or cross-tabulation data into a standardized format.
Similar to fold but allows the new output key and value fields
to be given alternative names
See the Vega-Lite lookup documentation.
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. 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.
Similar to lookup but returns the entire set of field values from the secondary data source when keys match. Accessed with via name provided in the fourth parameter.
Impute missing data. See the Vega-Lite impute documentation.
Impute missing data values. The first parameter is the data field to process; the second the key field to uniquely identify data objects within a group; the third customisable options.
1d window over which data imputation values are generated. The two
parameters should either be Just a number indicating the offset from the current
data object, or Nothing to indicate unbounded rows preceding or following the
current data object.
Key values to be considered for imputation.
Key values to be considered for imputation as a sequence of numbers between a start (first parameter), to less than an end (second parameter) in steps of the third parameter.
Imputation method to use when replacing values.
Allow imputing of missing values on a per-group basis. For use with the impute transform only and not a channel encoding.
New value to use when imputing with imValue.
See the Vega-Lite sample documentation
Randomly sample rows from a data source up to a given maximum.
See the Vega-Lite window transform field and window transform documentation.
Window transform for performing calculations over sorted groups of data objects such as ranking, lead/lag analysis, running sums and averages.
The first parameter is a list of tuples each comprising a window transform field definition and an output name. The second is the window transform definition.
trans =
transform
<< window [ ( [ wiAggregateOp opSum, wiField "Time" ], "TotalTime" ) ]
[ wiFrame Nothing Nothing ]An aggregrate operation to be used in a window transformation.
Window-specific operation to be used in a window transformation.
Numeric parameter for window-only operations that can be parameterised
(woPercentile, woLag, woLead and woNthValue).
Field for which to compute a window operation. Not needed for
operations that do not apply to fields such as opCount, woRank and woDenseRank.
Assign consecutive row number to values in a data object to be applied in a window transform.
Rank function to be applied in a window transform.
Dense rank function to be applied in a window transform.
Percentile of values in a sliding window to be applied in a window transform.
Cumulative distribution function to be applied in a window transform.
Value preceding the current object in a sliding window to be applied in a window transform.
Value preceding the current object in a sliding window to be applied in a window transform.
Value following the current object in a sliding window to be applied in a window transform.
First value in a sliding window to be applied in a window transform.
Last value in a sliding window to be applied in a window transform.
Nth value in a sliding window to be applied in a window transform.
Moving window for use by a window transform. The two parameters
should either be Just a number indicating the offset from the current data object,
or Nothing to indicate unbounded rows preceding or following the current data object.
Whether or not the sliding window frame in a window transform should ignore peer values (those considered identical by the sort criteria).
Fields for partitioning data objects in a window transform into separate windows. If unspecified, all points will be in a single group.
Comparator for sorting data objects within a window transform.
Indicate that the given field should be sorted in ascending order when performing a window transform.
Indicate that the given field should be sorted in descending order when performing a window transform.
Functions for declaring the type of visual marks used in the visualization.
An area mark for representing a series of data elements, such as in a stacked area chart or streamgraph.
Bar mark for histograms, bar charts etc.
Boxplot composite mark for showing summaries of statistical distributions.
Errorband composite mark for showing summaries of variation along a signal. By default no border is drawn. To add a border with default properties use maBorders with an empty list.
Errorbar composite mark for showing summaries of variation along a signal. By default no ticks are drawn. To add ticks with default properties use maTicks with an empty list.
Circle mark for symbolising points.
Geoshape determined by geographically referenced coordinates.
Line mark for symbolising a sequence of values.
Point mark for symbolising a data point with a symbol.
Rule line connecting two vertices.
Square mark for symbolising points.
Text mark to be displayed at some point location.
Short line (tick) mark for symbolising point locations.
Trail mark (line with variable width along its length).
See the Vega-Lite general mark, area mark, bar mark, hyperlink mark, line mark, point mark, text mark and tick mark property documentation.
Horizontal alignment of a text mark.
Rotation angle in degrees of a text mark.
Band size of a bar mark.
Vertical alignment of a text mark.
Offset between bars for a binned field using a bar mark.
Border properties for an errorband mark.
Whether or not a mark should be clipped to the enclosing group's dimensions.
Default color of a mark. Note that maFill and maStroke have higher
precedence and will override this if specified.
Cursor to be associated with a hyperlink mark.
Extent of whiskers used in a boxplot, error bars or error bands.
Hyperlink to be associated with a mark making it a clickable hyperlink.
Continuous band size of a bar mark.
Discrete band size of a bar mark.
Horizontal offset between a text mark and its anchor.
Vertical offset between a text mark and its anchor.
Default fill color of a mark.
Whether or not a mark's color should be used as the fill color instead of stroke color.
Fill opacity of a mark.
Font of a text mark. Can be any font name made accessible via
a css file (or a generic font like serif, monospace etc.).
Font size in pixels used by a text mark.
Font style (e.g. italic) used by a text mark.
Font weight used by a text mark.
Interpolation method used by line and area marks.
Overal opacity of a mark in the range 0 to 1.
Orientation of a non-stacked bar, tick, area or line mark.
Appearance of a point marker joining the vertices of a line or area mark.
Appearance of a line marker joining the vertices of an area mark.
Polar coordinate radial offset of a text mark from its origin.
Rule (main line) properties for the errorbar mark.
Shape of a point mark.
Whether or not month and weekday names are abbreviated in a text mark.
Size of a mark in square units.
Default stroke color of a mark.
Cap style of a mark's stroke.
Stroke dash style used by a mark. Determined by an alternating 'on-off' sequence of line lengths.
Number of pixels before the first line dash is drawn.
Line segment join style of a mark's stroke.
Rounded stroke join.
Bevelled stroke join.
Mitred stroke join.
Mitre limit at which to bevel a join between line segments of a mark's stroke.
Stroke opacity of a mark in the range 0 to 1.
Stroke width of a mark in pixel units.
Names of custom styles to apply to a mark. Each should refer to a named style defined in a separate style configuration.
Interpolation tension used when interpolating line and area marks.
Placeholder text for a text mark for when a text channel is not specified.
Polar coordinate angle (clockwise from north in radians) of a text mark from the origin determined by its x and y properties.
Thickness of a tick mark.
Tick properties for the errorbar mark.
Source of a mark's tooltip content.
X position offset for a mark.
Y position offset for a mark.
X2 position offset for a mark.
Y2 position offset for a mark.
Indicate horizontal mark orientation.
Indicate vertical mark orientation.
Cubic basis spline interpolation between points anchored at first and last points.
Open cubic basis spline interpolation between points, which may not intersect first and last points.
Closed cubic basis spline interpolation between points forming a polygon.
Bundle curve interpolation between points.
Cubic cardinal spline interpolation between points anchored at first and last points.
Open cubic cardinal spline interpolation between points, which may not intersect first and last points
Closed cubic cardinal spline interpolation between points forming a polygon.
Linear (straight) interpolation between points.
Cubic spline interpolation that preserves monotonicity between points.
Piecewise (stepped) constant interpolation function centred on each point in a sequence.
Piecewise (stepped) constant interpolation function after each point in a sequence.
Piecewise (stepped) constant interpolation function before each point in a sequence.
Specify a diamond symbol for a shape mark.
Specify an upward triangular symbol for a shape mark.
Specify a downward triangular symbol for a shape mark.
A custom symbol shape as an SVG path description.
No point marker to be shown on a line or area mark.
Transparent point marker to be placed on area or line mark. Useful for interactive selections.
Properties of a point marker that is overlaid on a line or area mark.
Properties of a line marker that is overlaid on an area mark.
Indicates no line marker on an area mark.
Band extent between the minumum and maximum values in a distribution.
Band extent between the 95% confidence intervals of a distribution.
Band extent between the lower and upper quartiles of a distribution.
A scaling of the interquartile range to be used as whiskers in a boxplot. For example a value of 1.5 would extend whiskers to ±1.5x the IQR from the mean.
Band extent as the standard error about the mean of a distribution.
Band extent as the standard deviation of a distribution.
Indicate tooltips are generated by data.
Indicate tooltips are generated by encoding (default).
See the CSS cursor documentation
Context menu cursor.
Progress cursor.
Crosshair cursor.
Vertical text cursor.
'Not allowed' cursor.
Scrolling cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Resizing cursor.
Grabbing cursor.
Types and functions for declaring which data fields (data) are mapped to which channels (position, color etc.).
Create an encoding specification from a list of channel encodings. These are
commonly built by chaining series of LabelledSpec generating functions together.
For example,
enc =
encoding
<< position X [ pName "month", pMType Temporal ]
<< position Y [ pName "score", pMType Quantitative ]
<< color [ mName "team", mMType Nominal ]Type of measurement to be associated with some channel.
Relates to where something appears in the visualization. See the Vega-Lite position documentation
Encode a position channel. The first parameter identifies the channel, the second a list of encoding options.
Type of position channel.
Name of the field used for encoding with a position channel.
Arrangement of views in a repeated composite view.
Level of measurement when encoding with a position channel.
Discretize numeric values into bins when encoding with a position channel.
Indicate that data encoded with position are already binned.
Form of time unit aggregation of field values when encoding with a position channel.
Title of a field when encoding with a position channel.
Compute some aggregate summary statistics for a field to be encoded with a position channel. The type of aggregation is determined by the given operation parameter.
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.
Axis properties used when encoding with a position channel. For no axis, provide an empty list.
Sort order for field when encoding with a position channel.
Type of stacking offset for field when encoding with a position channel.
Set the position to the width of the enclosing data space. Useful for justifying a mark to the right hand edge of a view. e.g. to position a mark at the right of the data rectangle:
enc =
encoding
<< position X [ pWidth ]Set the position to the height of the enclosing data space. Useful for placing a mark relative to the bottom edge of a view.
Imputation rules for a position channel. See the Vega-Lite impute documentation
Indicate sorting is to be applied from low to high.
Indicate sorting is to be applied from high to low.
Sort by the aggregated summary of a given field using a given aggregation
operation. e.g., sort 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" opMean, soDescending ]
]Sort by the aggregated summaries of the given fields (referenced by a repeat iteration) using a given aggregation operation.
Custom sort order listing data values explicitly.
Whether or not an axis baseline (domain) should be included as part of an axis.
Format to apply to labels on an axis.
Whether or not grid lines should be included as part of an axis.
Rotation angle in degrees of axis labels.
Overlap strategy for labels when they are too large to fit within the space devoted to an axis.
Padding in pixels between an axis and its text labels.
Whether or not axis labels should be displayed.
Maximum extent in pixels that axis ticks and labels should use.
Minimum extent in pixels that axis ticks and labels should use.
Offset to displace the axis from the edge of the enclosing group or data rectangle.
Orientation of an axis relative to the plot it is describing.
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.
Position of axis tick relative to a band (0 to 1).
Dates/times to appear along an axis.
Color of axis domain line.
Opacity of axis domain line.
Width of axis domain line.
Horizontal alignment of axis tick labels.
Vertical alignment of axis tick labels.
How or if labels should be hidden if they exceed the axis range. If
Nothing, no check for label size is made. A number specifies the permitted
overflow in pixels.
Color of axis tick label.
How or if labels at beginning or end of the axis should be aligned. Specifies
the distance threshold from an end-point within which labels are flush-adjusted
or if Nothing, no flush-adjustment made.
Number of pixels by which to offset flush-adjusted labels.
Font name of an axis label.
Font size of an axis label.
Font weight of an axis label.
Maximum length in pixels of axis tick labels.
Opacity of an axis label.
Color of axis ticks.
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).
Whether or not an extra axis tick should be added for the initial position of an axis.
Offset in pixels of an axis's ticks, labels and gridlines.
Opacity of axis ticks.
Whether or not axis tick positions should be rounded to nearest integer.
Whether or not an axis should include tick marks.
Tick mark size in pixels.
Desired step size for ticks. Will generate corresponding tick count and values.
Width of axis ticks.
Title to display as part of an axis. An empty string can be used to prevent a title being displayed.
Horizontal alignment of an axis title.
Angle in degrees of an axis title.
Vertical alignment of axis title.
Color of axis title.
Font name for an axis title.
Font size for an axis title.
Font weight of an axis title.
Maximum length in pixels of axis title.
Opacity of an axis title.
Padding in pixels between a title and axis.
X position of an axis title relative to the axis group.
Y position of an axis title relative to the axis group.
Numeric values to appear along an axis.
Drawing order of the axis relative to the other chart elements. 1 indicates axis is drawn in front of chart marks, 0 indicates it is drawn behind them.
No overlap strategy to be applied when there is not space to show all items on an axis.
Greedy overlap strategy to be applied when there is not space to show all items on an axis.
Give all items equal weight in overlap strategy to be applied when there is not space to show them all on an axis.
Relate to the appearance of the visual marks in the visualization such as their color or size.
Encode a size channel with a list of mark channel properties.
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.
Encode a fill channel. This acts in a similar way to encoding by color but
only affects the interior of closed shapes. If both fill and color encodings
are specified, fill takes precedence.
Encode a stroke channel. This acts in a similar way to encoding by color but
only affects the exterior boundary of marks.
Encode a stroke width channel.
Encode an opacity channel.
Encode a fill opacity channel. This acts in a similar way to encoding by opacity
but only affects the interior of closed shapes. If both fillOpacity and opacity
encodings are specified, fillOpacity takes precedence.
Encode a stroke opacity channel. This acts in a similar way to encoding by
opacity but only affects the exterior boundary of marks. If both opacity and
strokeOpacity are specified, strokeOpacity takes precedence for stroke encoding.
Encode a shape channel.
Field used for encoding with a mark property channel.
Reference in a mark channel to a field name generated by repeat. The
parameter identifies whether fields are to be laid out in columns or rows.
Level of measurement when encoding with a mark property channel.
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.
Discretize numeric values into bins when encoding with a mark property channel.
Indicate that data encoding with a mark are already binned.
Iputation rules for a mark channel. See the Vega-Lite impute documentation
Time unit aggregation of field values when encoding with a mark property channel.
Title of a field when encoding with a mark property channel.
Compute some aggregate summary statistics for a field to be encoded with a mark property channel. The type of aggregation is determined by the given operation parameter.
Properties of a legend that describes a mark's encoding. For no legend, provide an empty list as a parameter.
SVG path string used when encoding with a mark property channel. Useful for providing custom shapes.
Literal numeric value when encoding with a mark property channel.
Literal string value when encoding with a mark property channel.
Boolean value when encoding with a mark property channel.
A gradient legend for continuous quantitative data.
Limit height of legend entries.
Horizontal padding between symbol legend entries.
Number of columns in which to arrange symbol legend entries.
Legend corner radius.
Direction of a legend.
Legend background color.
Formatting pattern for legend labels.
Length in pixels of the primary axis of a color ramp legend.
Thickness in pixels of a color ramp legend.
Color for strokes in a color ramp legend.
Width for strokes in a color ramp legend.
Alignment to apply to symbol legends rows and columns.
Horizontal alignment of legend labels.
Vertical alignment of legend labels.
Color for legend labels.
Font for legend labels.
Font size legend labels.
Maximum width for legend labels in pixel units.
Offset for legend labels.
Strategy for resolving overlapping legend labels.
Offset in pixels of a legend from the edge of its enclosing group or data rectangle.
Position of a legend in a scene.
Padding in pixels between a legend and axis.
Vertical spacing in pixel units between a symbol legend entries.
Legend border color.
Legend border stroke width.
Legend symbol fill color.
Legend symbol size.
Legend symbol outline color.
Legend symbol stroke width.
Legend symbol type.
Number of tick marks in a quantitative legend.
Title of a legend.
Horizontal alignment for legend titles.
Vertical alignment for legend titles.
Color for legend title.
Font for legend titles.
Font size for legend titles.
Font weight for legend titles.
Maximum size in pixel units for legend titles.
Spacing in pixel units between title and legend.
Type of legend.
An explicit set of legend values.
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.
Position legend to the left of the visualization it describes.
Position legend to the right of the visualization it describes.
Position legend to the top-left of the visualization it describes.
Position legend to the top-right of the visualization it describes.
Position legend to the bottom-left of the visualization it describes.
Position legend to the bottom-right of the visualization it describes.
Do not perform automatic legend positioning (allows legend to be located explicitly
via x y coordinates).
An explicit set of numeric legend values.
An explicit set of legend strings.
An explicit set of legend date-times.
Relate to the appearance of the text and tooltip elements of the visualization. See the Vega-Lite text documentation
Encode a text channel.
Encode a tooltip channel. To encode multiple tooltip values with a mark, use tooltips.
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.
Name of the field used for encoding with a text channel.
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.
Level of measurement when encoding with a text channel.
Discretize numeric values into bins when encoding with a text channel.
Indicate that data encoded with a text channel are already binned.
Compute some aggregate summary statistics for a field to be encoded with a text channel. The type of aggregation is determined by the given operation parameter.
Time unit aggregation of field values when encoding with a text channel.
Title of a field when encoding with a text or tooltip channel.
Formatting pattern for a field when encoding with a text channel.
Weight options for a font.
Relates to a clickable URL destination of a mark. 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. See the Vega-Lite hyperlink documentation
Encode a hyperlink channel. The first parameter is a list of hyperlink channel properties that characterise the hyperlinking such as the destination URL and cursor type.
Field used for encoding with a hyperlink channel.
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.
Level of measurement when encoding with a hyperlink channel.
Discretize numeric values into bins when encoding with a hyperlink channel.
Indicate that data encoded with a hyperlink channel are already binned.
Compute some aggregate summary statistics for a field to be encoded with a hyperlink channel. The type of aggregation is determined by the given operation parameter.
Time unit aggregation of field values when encoding with a hyperlink channel.
Literal string value when encoding with a hyperlink channel.
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 order documentation.
Encode an order channel with a list of order field definitions.
Name of the field used for encoding with an order channel.
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.
Level of measurement when encoding with an order channel.
Discretize numeric values into bins when encoding with an order channel.
Compute some aggregate summary statistics for a field to be encoded with an order channel. The type of aggregation is determined by the given operation parameter.
Sort order to be used by an order channel.
Time unit aggregation of field values when encoding with an order channel.
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 facet documentation. See also, 'faceted view composition' for a more flexible (but more verbose) way of defining faceted views.
Encode a new facet to be arranged in rows. The first parameter is a list of facet properties that define the faceting channel.
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.
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. See the Vega-Lite documentation.
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.
Field used for encoding with a level of detail (grouping) channel.
Level of measurement when encoding with a level of detail (grouping) channel.
Compute some aggregate summary 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.
Discretize numeric values into bins when encoding with a level of detail (grouping) channel.
Set the iputation rules for a detail channel. See the Vega-Lite impute documentation
Form of time unit aggregation of field values when encoding with a level of detail (grouping) channel.
Used to specify how the encoding of a data field should be applied. See the Vega-Lite scale documentation.
Type of scaling to apply.
Custom scaling domain.
Range of a scaling. The type of range depends on the encoding channel.
Color scheme used by a color scaling. The first parameter is the name of the scheme (e.g. "viridis") and the second an optional specification of the number of colors to use (list of one number), or the extent of the color range to use (list of two numbers between 0 and 1).
Padding in pixels to apply to a scaling.
Inner padding to apply to a band scaling.
Outer padding to apply to a band scaling.
Distance between the starts of adjacent bands in a band scaling. If
Nothing is provided the distance is determined automatically.
Whether or not numeric values in a scaling are rounded to integers.
Whether or not values outside the data domain are clamped to the minimum or maximum value.
Interpolation method for scaling range values.
'Nice' minimum and maximum values in a scaling (e.g. multiples of 10).
Whether or not a numeric scaling should be forced to include a zero value.
Reverse the order of a scaling.
A linear band scale.
An ordinal band scale.
A log scale. Defaults to log of base 10, but can be customised by setting scBase to some other value.
The base to use for log scaling.
A power scale. The exponent to use for scaling is specified with scExponent.
The exponent to use for power scaling.
A quantile scale.
A quantizing scale.
A sequential scale.
A threshold scale.
Name of a pre-defined scale range (e.g. symbol or diverging).
Numeric scale range. Depending on the scaling this may be a [min, max] pair, or a list of explicit numerical values.
Text scale range for discrete scales.
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 scDomain and scRange 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" )
]
]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. Convenience function equivalent to specifying separate scDomain and
scRange 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" ))
]Numeric values that define a scale domain.
String values that define a scale domain.
Date-time values that define a scale domain.
Specify an unaggregated scale domain (type of data in scale).
Scale domain based on a named interactive selection.
Nice time intervals that try to align with rounded milliseconds.
Desired number of tick marks in a 'nice' scaling.
'Nice' temporal interval values when scaling.
For color interpolation types, see the Vega-Lite continuous scale documentation.
Cube helix color interpolation for continuous color scales using the given gamma value (anchored at 1).
Long-path cube helix color interpolation for continuous color scales using the given gamma value (anchored at 1).
HCL color interpolation for continuous color scales.
HCL color interpolation in polar coordinate space for continuous color scales.
HSL color interpolation for continuous color scales.
HSL color interpolation in polar coordinate space for continuous color scales.
Lab color interpolation for continuous color scales.
RGB color interpolation for continuous color scales using the given gamma value (anchored at 1).
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 (e.g. two position scales in a layered
visualization) the rules for resolving them can be defined with resolve.
See the
Vega-Lite composition documentation
Assign a list of specifications to superposed layers in a visualization.
Specifications to be juxtaposed horizontally in a visualization.
Specifications to be juxtaposed vertically in a visualization.
Alignment to apply to grid rows and columns generated by a composition operator. This version sets the same alignment for rows and columns.
Similar to align but with independent alignments for rows (first parameter) and columns (second parameter).
Subviews in a composed view to be aligned into a clean grid structure where all rows and columns are of the same size (based on maximum subview size).
Subviews in a composed view to be aligned into a clean grid structure where each row or column may be of variable size.
Flow layout is to be applied to composed views, in which adjacent subviews are placed one after the other.
Bounds calculation method to use for determining the extent of a sub-plot in
a composed view. If set to Full the entire calculated bounds including axes,
title and legend are used; if Flush only the width and height values for the
sub-view will be used.
Bounds calculation should use the entire plot area (including axes, title, and legend).
Bounds calculation should take only the specified width and height values for a sub-view. Useful when attempting to place sub-plots without axes or legends into a uniform grid structure.
Spacing between sub-views in a composition operator.
Similar to spacing but with independent spacing for rows (first parameter) and columns (second parameter).
Whether or not sub-views specified in a composition operator should be centred relative to their respective rows and columns.
Similar to center but with independent centring for rows and columns.
Controlling the (in)dependence between composed views. See the Vega-Lite resolve documentation.
Determine whether scales, axes or legends in composite views should share channel encodings.
Define a resolution option to be applied when scales, axes or legends in composite views share channel encodings. This allows different color encodings to be created in a layered view, which would otherwise 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.
resolve
<< resolution (reScale [ ( chY, reIndependent ) ])Scale domain should be independent of others in a composite visualization.
Indicate how a channel's axes should be resolved when defined in more than one view in a composite visualization.
Indicate how a channel's legends should be resolved when defined in more than one view in a composite visualization.
Indicate how a channel's scales should be resolved when defined in more than one view in a composite visualization.
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. See the Vega-Lite facet documentation
Define the fields that will be used to compose rows and columns of a set of
small multiples. Used when the encoding 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)
]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.
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.
Fields to be used to facet a view in rows or columns creating a set of small
multiples. Used when 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
]The mapping between a column and its field definitions in a set of faceted small multiples.
Tthe mapping between a row and its field definitions in a set of faceted small multiples.
Field used for encoding with a facet channel.
Level of measurement when encoding with a facet channel.
Compute some aggregate summary statistics for a field to be encoded with a facet channel. The type of aggregation is determined by the given operation parameter.
Discretize numeric values into bins when encoding with a facet channel.
Guide that spans a collection of faceted plots, each of which may have their own axes.
Form of time unit aggregation of field values when encoding with a facet channel.
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. For repeated and faceted specs, the entire specification is provided.
Define a specification object for use with faceted and repeated small multiples.
spec = ...
toVegaLite
[ facet [ rowBy [ fName "Origin", fMType Nominal ] ]
, specifcation spec
]Column arrangement in a repeated/faceted view.
Row arrangement in a repeated/faceted view.
Header label rotation angle (in degrees) for a faceted view. A 'label' is the title for each sub-plot in a faceted view.
Header label text color for a faceted view.
Header label font for a faceted view.
Header label font size for a faceted view.
Maximum length of a header label in a faceted view.
Spacing in pixels between facet labels and the main plot area.
Header title in a faceted view. A 'title' is the overall title describing the collection of faceted plots.
Anchor position of a header title in a faceted view.
Text angle of a header title in a faceted view.
Vertical alignment of a header title in a faceted view.
Text color of a header title in a faceted view.
Title font in a faceted view.
Title font weight in a faceted view.
Title font size in a faceted view.
Maximum length of a header title in a faceted view.
Spacing in pixels between the main facet title and labels.
Header format for a faceted view.
Create a full selection specification from a list of selections.
sel =
selection
<< select "view" seInterval [ seBindScales ] []
<< select "myBrush" seInterval []
<< select "myPaintbrush" seMulti [ seOn "mouseover", seNearest True ]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.
Indicate multiple interactive mark selections can be made (e.g. with shift-click).
Indicate a draggable bounding rectangle can be made for selecting all items that intersect with it.
Make a selection empty by default when nothing selected.
Binding to some input elements as part of a named selection.
Enable two-way binding between a selection and the scales used in the same view.
Encoding channels that form a named selection.
Field names for projecting a selection.
Whether or not a selection should capture nearest marks to a pointer rather than an exact position match.
Vega event stream that triggers a selection.
Strategy that determines how selections’ data queries are resolved when applied in a filter transform, conditional encoding rule, or scale domain.
Appearance of an interval selection mark (dragged rectangle).
Predicate expression that determines a toggled selection. See the Vega-Lite toggle documentation
Translation selection transformation used for panning a view. See the Vega-Lite translate documentation
Zooming selection transformation used for zooming a view. See the Vega-Lite zoom documentation
Range slider input element that can bound to a named field value.
Checkbox input element that can bound to a named field value.
Radio box input element that can bound to a named field value.
Select input element that can bound to a named field value.
Text input element that can bound to a named field value.
Number input element that can bound to a named field value.
Date input element that can bound to a named field value.
Time input element that can bound to a named field value.
Month input element that can bound to a named field value.
Week input element that can bound to a named field value.
Local time input element that can bound to a named field value.
Telephone number input element that can bound to a named field value.
Color input element that can bound to a named field value.
Delay to introduce when processing input events in order to avoid unnecessary event broadcasting.
CSS selector indicating the parent element to which an input element should be added. Allows the option of the input element to be outside the visualization container.
Options for a radio or select input element.
Minimum slider value for a range input element.
Maximum slider value for a range input element.
Custom label for a radio or select input element.
Minimum input element range slider increment.
Initial placeholding text for input elements such as text fields.
Fill color of an interval selection mark (dragged rectangular area).
Fill opacity of an interval selection mark in the range 0 to 1.
Stroke color of an interval selection mark.
Stroke dash style of an interval selection mark.
Stroke dash offset of an interval selection mark.
Stroke opacity of an interval selection mark in the range 0 to 1.
Stroke width of an interval selection mark.
Determines how selections are made across multiple views. See the Vega-lite resolve selection documentation.
One selection available across all subviews (default).
Each subview contains its own brush and marks are selected if they lie within any of these individual selections.
Each subview contains its own brush and marks are selected if they lie within all of these individual selections.
To make channel encoding conditional on the result of some interaction, use mSelectionCondition (and its 't' and 'h' variants). Similarly mDataCondition (and its 't' and 'h' variants) will encode a mark conditionally depending on some data properties such as whether a datum is null or an outlier.
For interaction, once a selection has been defined and named, supplying a set of
encodings allow mark encodings to become dependent on that selection.
mSelectionCondition is followed firstly a (Boolean) selection and then an
encoding if that selection is true and another encoding to be applied if it is false.
The color specification below states "whenever data marks are selected with an
interval mouse drag, encode the cylinder field with an ordinal color scheme,
otherwise 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 encode a mark depending on whether any
predicate tests are satisfied. Unlike selections, multiple conditions and associated
encodings can be specified. Each test condition is evaluated in order and only on
failure of the test does encoding proceed to the next test. If no tests are true,
the encoding in the final parameter is applied in a similar way to 'case of'
expressions:
enc =
encoding
<< position X [ pName "value", pMType Ordinal ]
<< color
[ mDataCondition
[ ( expr "datum.value < 40", [ mStr "blue" ] )
, ( expr "datum.value < 50", [ mStr "red" ] )
, ( expr "datum.value < 60", [ mStr "yellow" ] )
]
[ mStr "black" ]
]See the Vega-Lite documentation.
Make a mark channel conditional on interactive selection. The first parameter is a selection condition to evaluate; the second the encoding to apply if that selection is true; the third parameter is the encoding if the selection is false.
color
[ mSelectionCondition (selectionName "myBrush")
[ mName "myField", mMType Ordinal ]
[ mStr "grey" ]
]Make a mark channel conditional on one or more predicate expressions. The first parameter is a list of tuples each pairing a test condition with the encoding if that condition evaluates to true. The second is the encoding if none of the tests are true.
color
[ mDataCondition [ ( expr "datum.myField === null", [ mStr "grey" ] ) ]
[ mStr "black" ]
]Make a text channel conditional on interactive selection. The first parameter is a selection condition to evaluate; the second the encoding to apply if that selection is true; the third parameter is the encoding if the selection is false.
Make a text channel conditional on one or more predicate expressions. The first parameter is a list of tuples each pairing an expression to evaluate with the encoding if that expression is true. The second is the encoding if none of the expressions are evaluated as true.
Make 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.
Make 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.
Apply an 'and' Boolean operation as part of a logical composition.
and (expr "datum.IMDB_Rating === null") (expr "datum.Rotten_Tomatoes_Rating === null")Apply an 'or' Boolean operation as part of a logical composition.
Apply a negation Boolean operation as part of a logical composition. Boolean operations can be nested to any level.
not (and (expr "datum.IMDB_Rating === null") (expr "datum.Rotten_Tomatoes_Rating === null"))Expression that should evaluate to either true or false. Can use any valid Vega expression.
Interactive selection that will be true or false as part of a logical composition. e.g., 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")))Name a selection that is used as part of a conditional encoding.
color
[ mSelectionCondition (selectionName "myBrush")
[ mName "myField", mMType Nominal ]
[ mStr "grey" ]
]Configuration options that affect the entire visualization. These are in addition to the data and transform options described above. See the Vega-Lite top-level spec documentation
Name to be associated with a visualization.
Title to be displayed in the visualization.
Description to be associated with a visualization.
Override the default height of the visualization. If not specified the height will be calculated based on the content of the visualization.
Override the default width of the visualization. If not specified the width will be calculated based on the content of the visualization.
Padding around the visualization in pixel units. The way padding is interpreted
will depend on the autosize properties.
Padding around a visualization in pixel units. The four parameters refer to left, top, right, and bottom edges respectively.
Declare the way the view is sized. See the Vega-Lite autosize documentation.
enc = ...
toVegaLite
[ width 250
, height 300
, autosize [ asFit, asPadding, asResize ]
, dataFromUrl "data/population.json" []
, bar []
, enc []
]Interpret visualization dimensions to be for the data rectangle (external padding added to this size).
Interpret visualization dimensions to be for the entire visualization (data rectangle is shrunk to accommodate external decorations padding).
Automatically expand size of visualization from the given dimensions in order to fit in all supplemtary decorations (legends etc.).
Interpret visualization width to be for the entire visualization (data rectangle is shrunk to accommodate external padding).
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.
Allows default properties for most marks and guides to be set. See the Vega-Lite configuration documentation.
Create a single global configuration from a list of configuration specifications. See the Vega-Lite documentation.
config =
configure
<< configuration (coAxis [ axcoDomainWidth 1 ])
<< configuration (coView [ vicoStroke Nothing ])
<< configuration (coSelection [ ( seSingle, [ seOn "dblclick" ] ) ])A configuration option to be applied globally across the visualization.
Configure the default appearance of area marks.
Configure the default sizing of visualizations.
Configure the default appearance of axes.
Configure the default appearance of x-axes.
Configure the default appearance of y-axes.
Configure the default appearance of left-side axes.
Configure the default appearance of right-side axes.
Configure the default appearance of top-side axes.
Configure the default appearance of bottom-side axes.
Configure the default appearance of axes with band scaling.
Configure the default background color of visualizations.
Configure the default appearance of bar marks.
Configure the default appearance of circle marks.
Configure the default title style for count fields.
Configure the default title generation style for fields.
Configure the default appearance of geoshape marks.
Configure the default appearance of legends.
Configure the default appearance of line marks.
Configure the default appearance of facet headers.
Configure the default mark appearance.
Configure the default appearance of a named style.
Configure the default number formatting for axis and text labels.
Configure the default padding in pixels from the edge of the of visualization to the data rectangle.
Configure the default appearance of point marks.
Configure the default style of map projections.
Configure the default range properties used when scaling.
Configure the default appearance of rectangle marks.
Configure the default handling of invalid (null and NaN) values. If true,
invalid values are skipped or filtered out when represented as marks.
Configure the default appearance of rule marks.
Configure the default scale properties used when scaling.
Configure the default appearance of selection marks.
Configure the default appearance of square marks.)
Configure the default stack offset style for stackable marks.
Configure the default appearance of text marks.
Configure the default appearance of tick marks.
Configure the default style of visualization titles.
Configure the default time format for axis and legend labels.
Configure the default style of trail marks.
Configure the default single view style.
See the Vega-Lite axis config documentation.
Default axis band position.
Whether or not an axis domain should be displayed by default.
Default axis domain color.
Default axis domain opacity.
Default axis domain width style.
Default maximum extent style.
Default minimum extent style.
Whether or not an axis grid is displayed by default.
Default axis grid color style.
Default axis line dash style.
Default axis grid line opacity.
Default axis grid line width.
Whether or not an axis has labels by default.
Default axis label horizontal alignment.
Default axis label angle.
Default axis label vertical alignment.
Default axis label bounding when label exceeds available space. If Nothing,
no check for label size is made. A number specifies the permitted overflow in pixels.
Default axis label color.
Default label alignment at beginning or end of the axis. Specifies the distance
threshold from an end-point within which labels are flush-adjusted or if Nothing,
no flush-adjustment made.
Defailt number of pixels by which to offset flush-adjusted labels.
Default axis label font weight.
Default axis label font.
Default axis label font size.
Default axis label limit (how much a label can extend beyond the left/bottom or right/top of the axis line).
Default axis label opacity.
Default axis label overlap strategy for cases where labels cannot fit within the allotted space.
Default axis label padding (space between labels in pixels).
Whether or not an axis should use short time labels by default.
Whether or not an axis should show ticks by default.
Default axis tick mark color.
Whether or not by default an extra axis tick should be added for the initial position of axes.
Default offset in pixels of axis ticks, labels and gridlines.
Default opacity of axis ticks.
Whether or not axis tick labels use rounded values by default.
Default axis tick mark size.
Default step size for axis ticks.
Default axis tick mark width.
Default axis tick label horizontal alignment.
Default axis title angle.
Default axis title vertical alignment.
Default axis title color.
Default axis title font.
Default axis title font weight.
Default axis title font size.
Default axis title maximum size.
Default opacity of axis titles.
Default axis title padding between axis line and text.
Default axis x-position relative to the axis group.
Default axis y-position relative to the axis group.
Default maximum height of legend entries.
Default horizontal padding between symbol legend entries.
Default number of columns in which to arrange symbol legend entries.
Default legend corner radius.
Default background legend color.
Default legend position relative to the main plot content.
Default offset in pixel units between the legend and the enclosing group or data rectangle.
Default legend border color.
Default legend border stroke dash style.
Default legend border stroke width.
Default spacing in pixel units between a legend and axis.
Default vertical spacing in pixel units between legend symbol entries.
Default direction of a color ramp legend.
Default vertical alignment for labels in a color ramp legend.
Default maximum allowable length for labels in a color ramp legend.
Default vertical offset in pixel units for labels in a color ramp legend.
Default color for strokes in a color ramp legend.
Default width for strokes in a color ramp legend.
Default height of a color ramp legend.
Default width of a color ramp legend.
Defailt alignment to apply to symbol legends rows and columns.
Default horizontal alignment of legend labels.
Default vertical alignment of legend labels.
Default color for legend labels.
Default font for legend labels.
Default font size legend labels.
Default maximum width for legend labels in pixel units.
Default offset for legend labels.
Strategy for resolving overlapping legend labels.
Whether or not time labels are abbreviated by default in a legend.
Default spacing between legend items.
Default legend symbol fill color for when no fill scale color in legend encoding.
Default legend symbol stroke color for when no stroke scale color in legend encoding.
Default direction of a symbol legend.
Default legend symbol fill color.
Default horizontal pixel offset for legend symbols.
Default legend symbol size.
Default legend symbol outline color.
Default legend symbol stroke width.
Default legend symbol type.
Default horizontal alignment for legend titles.
Default vertical alignment for legend titles.
Default color legend titles.
Default font for legend titles.
Default font size for legend titles.
Default font weight for legend titles.
Default maximum size in pixel units for legend titles.
Default spacing in pixel units between title and legend.
Default inner padding for x and y band-ordinal scales.
Default outer padding for x and y band-ordinal scales.
Default inner padding for x and y band-ordinal scales of bar marks.
Default outer padding for x and y band-ordinal scales of bar marks.
Default inner padding for x and y band-ordinal scales of rect marks.
Default outer padding for x and y band-ordinal scales of rect marks.
Whether or not by default values that exceed the data domain are clamped to the min/max range value.
Default maximum value for mapping quantitative fields to a bar's size/bandSize.
Default minimum value for mapping quantitative fields to a bar's size/bandSize.
Default maximum value for mapping a quantitative field to a text mark's size.
Default minimum value for mapping a quantitative field to a text mark's size.
Default maximum opacity (in the range [0, 1]) for mapping a field to opacity.
Default minimum opacity (0 to 1) for mapping a field to opacity.
Default maximum size for point-based scales.
Default minimum size for point-based scales (when not forced to start at zero).
Default maximum stroke width for rule, line and trail marks.
Default minimum stroke width for rule, line and trail marks.
Default padding for point-ordinal scales.
Default range step for band and point scales when the mark is not text.
Whether or not numeric values are rounded to integers when scaling. Useful for snapping to the pixel grid.
Default range step for x band and point scales of text marks.
Whether or not to use the source data range before aggregation.
Default color scheme for categorical ranges.
Default diverging color scheme.
Default 'heatmap' color scheme.
Default ordinal color scheme.
Default ramp (continuous) color scheme.
Default color scheme symbols.
Default anchor position when placing titles.
Default angle when orientating titles.
Default vertical alignment when placing titles.
Default color when showing titles.
Default font when showing titles.
Default font size when showing titles.
Default font weight when showing titles.
Default maximum length in pixel units when showing titles.
Default offset in pixel units of titles relative to the chart body.
Default placement of titles relative to the chart body.
Default width of single views (e.g. each view in a trellis plot).
Default height of single views (e.g. each view in a trellis plot).
Whether or not by default single views should be clipped.
Default fill color for single views.
Default fill opacity for single views.
Default stroke color for single views. If Nothing is provided,
no strokes are drawn around the view.
Default stroke opacity for single views.
Default stroke width of single views.
Default stroke dash style for single views.
Default stroke dash offset for single views.
Field titles to be displayed fully as 'Sum of field', 'Year of date' etc.
Field titles to be displayed as 'SUM(field)', 'YEAR(date)' etc.
Field titles to be displayed simply by their name without additional text.
In addition to more general data types like integers and string, the following types can carry data used in specifications.
A true value used for functions that can accept a Boolean literal or a reference
to something that generates a Boolean value. Convenience function equivalent to boo True
A false value used for functions that can accept a Boolean literal or a
reference to something that generates a Boolean value. Convenience function
equivalent to boo False
A list of Boolean data values.
List of date-time data values.
List of numeric data values.
A list of string data values.
See the Vega-Lite dateTime documentation and the Vega-Lite time unit documentation.
Millisecond of a second (0-999).
Idntifies a month of the year.
Day of the week.
Hours and minutes time unit used for discretizing temporal data.
Hours, minutes and seconds time unit used for discretizing temporal data.
Milliseconds time unit used for discretizing temporal data.
Minutes and seconds time unit used for discretizing temporal data.
Month, day of month and hour of day time unit used for discretizing temporal data.
Year quarter and month time unit used for discretizing temporal data.
Seconds and milliseconds time unit used for discretizing temporal data.
Year and year quarter time unit used for discretizing temporal data.
Year, quarter and month time unit used for discretizing temporal data.
Year, month and day of month time unit used for discretizing temporal data.
Year, month, day of month and hour of day time unit used for discretizing temporal data.
Time unit used for discretizing temporal data.
Time unit used for discretizing temporal data.
UTC version of a given a time (coordinated universal time, independent of local
time zones or daylight saving). To encode a time as UTC (coordinated universal time,
independent of local time zones or daylight saving), just use this function to convert
another TimeUnit generating function. For example,
encoding
<< position X [ pName "date", pMType Temporal, pTimeUnit (utc yearMonthDateHours) ]Types that are not specified directly, provided here for reference with links to the functions that generate them.
Generated by functions prefixed with ax, for example axBandPosition.
Generated by functions prefixed with axco.
Generated with coArea, coAutosize, coAxis, coAxisX, coAxisY, coAxisLeft, coAxisRight, coAxisTop, coAxisBottom, coAxisBand, coBackground, coBar, coCircle, coCountTitle, coFieldTitle, coGeoshape, coHeader, coLegend, coLine, coMark, coNamedStyle, coNumberFormat, coPadding, coPoint, coProjection, coRange, coRect, coRemoveInvalid, coRule, coScale, coSelection, coSquare, coStack, coText, coTick, coTitle, coTimeFormat, coTrail and coView.
Generated by functions that start with cu.
Generated by ftVerbal, ftFunction and ftPlain.
Generated by fiEqual, fiLessThan, fiLessThanEq, fiGreaterThan, fiGreaterThanEq, fiExpr, fiCompose, fiSelection, fiOneOf, fiRange and fiValid.
Generated by csv, dsv, tsv, parse, jsonProperty, topojsonFeature and topojsonMesh.
Generated by geoPoint, geoPoints, geoLine, geoLines, geoPolygon and geoPolygons.
The imputation method to use when replacing values.
Generated by inDebounce, inElement, inOptions, inMin, inMax, inName, inStep and inPlaceholder.
Generated by hName, hRepeat, hMType, hBin, hBinned, hAggregate, hTimeUnit, hDataCondition, hSelectionCondition and hStr.
Generated by leGradient and leSymbol.
Generated by functions prefixed with leco.
Generated by loLeft, loTopLeft, loTopRight, loRight, loBottomRight, loBottomLeft and loNone.
Generated by functions prefied with le. For example leCornerRadius.
Generated by miBasis, miBasisClosed, miBasisOpen, miBundle, miCardinal, miCardinalClosed, miCardinalOpen, miLinear, miLinearClosed, miMonotone, miStepwise, miStepAfter and miStepBefore.
Generated by moHorizontal and moVertical.
Generated by maAlign, maAngle, maBandSize, maBaseline, maBinSpacing, maBorders, maClip, maColor, maCursor, maHRef, maContinuousBandSize, maDiscreteBandSize, maDx, maDy, maExtent, maFill, maFilled, maFillOpacity, maFont, maFontSize, maFontStyle, maFontWeight, maInterpolate, maLine, maOpacity, maOrient, maPoint, maRadius, maRule, maShape, maShortTimeLabels, maSize, maStroke, maStrokeCap, maStrokeDash, maStrokeDashOffset, maStrokeJoin, maStrokeMiterLimit, maStrokeOpacity, maStrokeWidth, maStyle, maTension, maText, maTheta, maThickness, maTicks, maTooltip, maXOffset, maYOffset, maX2Offset and maY2Offset.
Generated by pmNone, pmTransparent and pmMarker.
Generated by prType, prClipAngle, prClipExtent, prCenter, prRotate, prPrecision, prCoefficient, prDistance, prFraction, prLobes, prParallel, prRadius, prRatio, prSpacing and prTilt.
Generated by functions prefixed with raco.
Generated by rowFields and columnFields.
Generated by reShared and reIndependent.
Generated by scLinear, scPow, scSqrt, scLog, scTime, scUtc, scSequential, scOrdinal, scBand, scPoint, scBinLinear, scBinOrdinal, scQuantile, scQuantize and scThreshold.
Generated by doNums, doStrs, doDts, doSelection and doUnaggregated.
Generated by niTrue, niFalse, niMillisecond, niSecond, niMinute, niHour, niDay, niWeek, niMonth, niYear, niTickCount and niInterval.
Generated by scType, scDomain, scRange, scScheme, scPadding, scPaddingInner, scPaddingOuter, scRangeStep, scRound, scClamp, scInterpolate, scNice, scExponent, scBase, scZero and scReverse.
Generated by functions prefixed by saco
Generated by seInterval, seSingle and seMulti.
Generated by smFill, smFillOpacity, smStroke, smStrokeDash, smStrokeDashOffset, smStrokeOpacity and smStrokeWidth.
Generated by seBind, seBindScales,seEmpty, seEncodings, seFields, seNearest, seOn, seResolve, seSelectionMark, seToggle, seTranslate and seZoom.
Generated by seGlobal, seUnion and seIntersection.
Generated by stAscending, wiAscending, stDescending and wiDescending.
Generated by soAscending, soDescending, soByField, soByRepeat and soCustom.
Generated by stZero, stCenter, stNormalize and stNone.
Generated by symCircle, symSquare, symCross, symDiamond, symTriangleUp, symTriangleDown and symPath.
Generated by tName, tRepeat, tMType, tBin, tBinned, tAggregate, tTimeUnit, tTitle, tSelectionCondition, tDataCondition and tFormat.
Generated by date, day, hours, hoursMinutes, hoursMinutesSeconds, milliseconds, minutes, minutesSeconds, month, monthDate, quarter, quarterMonth, seconds, secondsMilliseconds, year, yearQuarter, yearQuarterMonth, yearMonth, yearMonthDate, yearMonthDateHours, yearMonthDateHoursMinutes, yearMonthDateHoursMinutesSeconds and utc.
Generated by functions prefixed by tico.
Generated by ttEncoding and ttData.
Generated by functions prefixed with vico.
Generated by wiAggregateOp, wiOp, wiParam and wiField.
Generated by woRowNumber, woRank, woDenseRank, woPercentRank, woCumeDist, woPercentile, woLag, woLead, woFirstValue, woLastValue, and woNthValue.
Generated by wiFrame, wiIgnorePeers, wiGroupBy and wiSort.
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 data, mark and encoding specifications.
While simple functions like
barmay be provided directly, it is usually clearer to label more complex ones such as encodings as separate expressions.Specifications can be built up by chaining functions such as
dataColumnorposition. Functional composition using the<<operator allows this to be done compactly.