CARTO VL

CARTO VL is a JavaScript library to create custom Location Intelligence applications over vector rendering.

Glossary

Implicit cast

A implicit cast is a transformation done automatically (implicitly) by one CARTO VL expression to another one. Its purpose is to provide syntax sugar over another expression which is equivalent but more verbose and difficult.

For example, when using ramp($numericProperty, [red, blue]) the ramp expression will implicitly cast $numericProperty to linear($numericProperty), and the linear expression will implicitly cast that to linear($numericProperty, globalMin($numericProperty), globalMax($numericProperty)), which is a much larger and more verbose form, but it is semantically the same.

Others bucket

The others bucket is a category that is generated by some CARTO VL functions like buckets and top. This bucket will contain all the categories that were grouped together in the last place.

There is more information in the Data driven visualization guide

Variables

Variables are a way to store and reuse expressions. We use the @ notation followed by the name to declare and use the variable in the String API. The expression s.var('name') can also be used to refer to variables in the JavaScript API, that should be declared inside the variables scope. For example:

String API

1
2
3
4
const viz = new carto.Viz(`
  @size: 10
  width: @size
`);

Javascript API

1
2
3
4
5
6
7
const s = carto.expressions;
const viz = new carto.Viz({
  variables: {
    size: 10
  },
  width: s.var('size')
});

Variables can be accessed directly from the carto.Viz object. If variables do not contain dynamic (animation) or data-driven (properties) information can be also evaluated there:

1
viz.variables.size.value;  // 10

If the variables contain Properties (Data-driven variables), they can be evaluated from the feature object in the interactivity event callbacks (see carto.Interactivity).