vega-lite-api

vl.layer(…layer)

Create a new layered chart.

layer Method Overview

layer API Reference

# layer.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

# layer.background(value)

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

Default value: "white"

# layer.config(value)

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

# layer.data(data)

The input data specification.

The behavior of this method depends on the argument type:

# layer.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.

# layer.description(value)

Description of this mark for commenting purpose.

# layer.encode(…encoding)

Specify visual encodings for the mark.

# layer.facet(…values)

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

# layer.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.

# layer.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.

# layer.name(value)

Name of the visualization for later reference.

# layer.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

# layer.params(…params)

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

# layer.project(projection)

The cartographic projection to apply to geographical data.

# layer.render(…values)

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

# layer.repeat(…values)

Repeat a chart template to generate multiple plots.

# layer.resolve(value)

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

# layer.title(value)

Title for the plot.

# layer.toSpec(…values)

Return the Vega-Lite specification as a JavaScript object.

# layer.toString(…values)

Return the Vega-Lite specification as a JSON string.

# layer.toView(…values)

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

# layer.transform(…transform)

The data transformations to apply.

# layer.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.

# layer.view(value)

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

Default value: none (transparent)

# layer.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.