v5.0.0
Updates the Vega-Lite API for Vega-Lite version 5. VL v5 revises the previous selection abstraction into a more general parameters abstraction, supporting both dynamic variables and interactive selections.
Version 5 of the API is mostly, but not entirely, backwards compatible with version 4 of the API. In particular, the selection empty method now takes a boolean rather than a string, and should be applied to a predicate reference to a selection, not a selection definition.
Changelog
Changes from v4.0.0:
- Breaking:
emptyselection method takes a boolean and applies only to selection predicate references, not selection definitions. - Deprecated:
vl.selectSingleandvl.selectMultimethods, now usevl.selectPointinstead. - Deprecated:
mark.selectmethod, now usemark.paramsinstead. - Deprecated:
selection.initmethod, now usevalueinstead. - Add
vl.parammethod to define or reference variable parameters. - Add
vl.exprmethod to refer to Vega expression language statements. - Add
vl.configPointandvl.configIntervalmethods to define selection configurations. Typically one should usevl.selectPointandvl.selectIntervaldirectly. The config options can be used to provide reusable configurations viamark.config({ selection: { point: vl.configPoint() } }). - Add
vl.lookupSelectionmethod to specifylookuptransform parameters against an interactive selection. - Add
vl.specto take a (potentially partial) top-level specification as input. - Add
vl.renderto directly render a specification using thespecoption argument. - Update test cases.
Examples
Here is a scatter plot with dynamic query widgets written using v4 selections...
const cylYear = vl.selectSingle('CylYr')
.fields('Cylinders', 'Year')
.init({ Cylinders: 4, Year: 1977 })
.bind({ Cylinders: vl.slider(3, 8, 1), Year: vl.slider(1970, 1980, 1) });
return vl.markCircle()
.data('data/cars.json')
.transform(vl.calculate('year(datum.Year)').as('Year'))
.select(cylYear)
.encode(
vl.x().fieldQ('Horsepower'),
vl.y().fieldQ('Miles_per_Gallon'),
vl.color().if(cylYear, vl.color().fieldN('Origin')).value('grey')
);...and here is the updated version using v5 parameters.
const cylYear = vl.selectPoint('CylYr')
.fields('Cylinders', 'Year')
.value({ Cylinders: 4, Year: 1977 })
.bind({ Cylinders: vl.slider(3, 8, 1), Year: vl.slider(1970, 1980, 1) });
return vl.markCircle()
.data('data/cars.json')
.transform(vl.calculate('year(datum.Year)').as('Year'))
.params(cylYear)
.encode(
vl.x().fieldQ('Horsepower'),
vl.y().fieldQ('Miles_per_Gallon'),
vl.color().if(cylYear, vl.color().fieldN('Origin')).value('grey')
);