vega-lite-api

vl.spec(…values)

Create an arbitrary Vega-Lite specification.

spec Method Overview

spec API Reference

# spec.align(value)

The alignment to apply to grid rows and columns. The supported string values are "all", "each", and "none".

Alternatively, an object value of the form {"row": string, "column": string} can be used to supply different alignments for rows and columns.

Default value: "all".

# spec.autosize(value)

How the visualization size should be determined. If a string, should be one of "pad", "fit" or "none". Object values can additionally specify parameters for content sizing and automatic resizing.

Default value: pad

# spec.background(value)

CSS color property to use as the background of the entire view.

Default value: "white"

# spec.bounds(value)

The bounds calculation method to use for determining the extent of a sub-plot. One of full (the default) or flush.

Default value: "full"

# spec.center(value)

Boolean flag indicating if subviews should be centered relative to their respective rows or columns.

Default value: false

# spec.columns(value)

The number of columns to include in the view composition layout.

Default value: undefined – An infinite number of columns (a single row) will be assumed. This is equivalent to hconcat (for concat) and to using the column channel (for facet and repeat).

Note:

1) This property is only for:

2) Setting the columns to 1 is equivalent to vconcat (for concat) and to using the row channel (for facet and repeat).

# spec.concat(…value)

A list of views to be concatenated.

# spec.config(value)

Vega-Lite configuration object. This property can only be defined at the top-level of a specification.

# spec.data(data)

The input data specification.

The behavior of this method depends on the argument type:

# spec.datasets(value)

A global data store for named datasets. This is a mapping from names to inline datasets. This can be an array of objects or primitive values or a string. Arrays of primitive values are ingested as objects with a data property.

# spec.description(value)

Description of this mark for commenting purpose.

# spec.encoding(value)

A shared key-value mapping between encoding channels and definition of fields in the underlying layers.

# spec.facet(…values)

Facet a chart into sub-plots by partitioning data values.

# spec.facet(value)

Definition for how to facet the data. One of: 1) a field definition for faceting the plot by one field 2) An object that maps row and column channels to their field definitions

# spec.hconcat(…value)

A list of views to be concatenated and put into a row.

# spec.height(value)

The height of a visualization.

Default value: Based on config.view.continuousHeight for a plot with a continuous y-field and config.view.discreteHeight otherwise.

Note: For plots with row and column channels, this represents the height of a single view and the "container" option cannot be used.

See also: height documentation.

# spec.layer(…value)

Layer or single view specifications to be layered.

Note: Specifications inside layer cannot use row and column channels as layering facet specifications is not allowed. Instead, use the facet operator and place a layer inside a facet.

# spec.mark(value)

A string describing the mark type (one of "bar", "circle", "square", "tick", "line", "area", "point", "rule", "geoshape", and "text") or a mark definition object.

# spec.name(value)

Name of the visualization for later reference.

# spec.padding(value)

The default visualization padding, in pixels, from the edge of the visualization canvas to the data rectangle. If a number, specifies padding for all sides. If an object, the value should have the format {"left": 5, "top": 5, "right": 5, "bottom": 5} to specify padding for each side of the visualization.

Default value: 5

# spec.params(…params)

An array of parameters that may be simple variables or more complex selections that map user input to data queries.

# spec.projection(value)

An object defining properties of the geographic projection shared by underlying layers.

# spec.render(…values)

Compile and render the Vega-Lite visualization and return the DOM element containing the Vega View.

# spec.repeat(…values)

Repeat a chart template to generate multiple plots.

# spec.repeat(value)

Definition for fields to be repeated. One of: 1) An array of fields to be repeated. If "repeat" is an array, the field can be referred to as {"repeat": "repeat"}. The repeated views are laid out in a wrapped row. You can set the number of columns to control the wrapping. 2) An object that maps "row" and/or "column" to the listed fields to be repeated along the particular orientations. The objects {"repeat": "row"} and {"repeat": "column"} can be used to refer to the repeated field respectively.

# spec.resolve(value)

Scale, axis, and legend resolutions for view composition specifications.

# spec.spacing(value)

The spacing in pixels between sub-views of the concat operator.

Default value: 10

# spec.spec(value)

A specification of the view that gets repeated.

# spec.title(value)

Title for the plot.

# spec.toSpec(…values)

Return the Vega-Lite specification as a JavaScript object.

# spec.toString(…values)

Return the Vega-Lite specification as a JSON string.

# spec.toView(…values)

Compile the Vega-Lite specification and return the resulting Vega View object.

# spec.transform(…transform)

The data transformations to apply.

# spec.usermeta(value)

Optional metadata that will be passed to Vega. This object is completely ignored by Vega and Vega-Lite and can be used for custom metadata.

# spec.vconcat(…value)

A list of views to be concatenated and put into a column.

# spec.view(value)

An object defining the view background’s fill and stroke.

Default value: none (transparent)

# spec.width(value)

The width of a visualization.

Default value: Based on config.view.continuousWidth for a plot with a continuous x-field and config.view.discreteWidth otherwise.

Note: For plots with row and column channels, this represents the width of a single view and the "container" option cannot be used.

See also: width documentation.