Vega-Lite: A Grammar of Interactive Graphics
Summary (5 min read)
1 INTRODUCTION
- Grammars of graphics span a gamut of expressivity.
- Analysts rapidly author partial specifications of visualizations; the grammar applies default values to resolve ambiguities, and synthesizes lowlevel details to produce visualizations.
- Selections parameterize visual encodings by serving as input data, defining scale extents, and providing predicate functions for testing or filtering items.
- Through a range of examples, the authors demonstrate that Vega-Lite brings the advantages of high-level specification to interactive visualization.
2.1 Grammar-Based Visual Encoding
- Since the initial publication of Wilkinson’s The Grammar of Graphics [29] in 1999, formal grammars for statistical graphics have grown increasingly popular as a way to succinctly specify visualizations.
- Wilkinson’s work was quickly followed by the Stanford Polaris system [24], later commercialized as Tableau.
- Drawing from Wilkinson’s grammar and Polaris/Tableau, Vega-Lite similarly represents basic plots using a set of encoding definitions that map data attributes to visual channels such as position, color, shape, and size, and may include common data transformations such as binning, aggregation, sorting, and filtering.
- VegaLite specifications are compiled to full Vega specifications, hence the expressive gamut of Vega-Lite is a strict subset of that of Vega.
- Disparate views can also be combined into arbitrary dashboards, all within a unified algebraic model.
2.2 Specifying Interactions in Visualization Systems
- 19], little work has been done to develop a grammar for specifying interaction techniques.
- Wilkinson’s grammar includes no notion of interaction.
- Reactive Vega draws on Functional Reactive Programming techniques to formulate composable, declarative interaction primitives for data visualization.
- When a new event fires, it propagates to dependent signals; visual encodings that use them are automatically re-evaluated and re-rendered.
- Specifying common techniques can be time-consuming, requiring tens of lines of JSON, and it is difficult to know how to adapt techniques in pursuit of alternative designs.
3 THE VEGA-LITE GRAMMAR OF GRAPHICS
- Vega-Lite combines a grammar of graphics with a novel grammar of interaction.
- The authors describe Vega-Lite’s basic visual encoding constructs and an algebra for view composition.
- In prior work, Wongsuphasawat et al. [30] introduced the simplest Vega-Lite specification — here referred to as a unit specification — that defines a single Cartesian plot with a specific mark type to encode data (e.g., bars, lines, plotting symbols).
- Given multiple unit plots, the authors introduce layer, concat, facet, and repeat operators to provide an algebra for constructing composite views.
- Each operator is responsible for combining or aligning underlying scales and axes as needed.
3.1 Unit Specification
- A unit specification describes a single Cartesian plot, with a backing data set, a given mark-type, and a set of one or more encoding definitions for visual channels such as position (x, y), color, size, etc.
- Formally, an encoding is a seven-tuple: encoding := (channel, field, data-type, value, functions, scale, guide) Available visual encoding channels include spatial position (x, y), color, shape, size, and text.
- The field string denotes a data attribute to visualize, along with a given data-type (one of nominal, ordinal, quantitative or temporal).
- If not specified, Vega-Lite will automatically populate default properties based on the channel and data-type.
- For x and y channels, either a linear scale (for quantitative data) or an ordinal scale (for ordinal and nominal data) is instantiated, along with an axis.
3.2 View Composition Algebra
- Given multiple unit specifications, composite views can be created using a set of composition operators.
- Here the authors describe the set of supported operators.
- The authors use the term view to refer to any Vega-Lite specification, whether it is a unit or composite specification.
3.2.1 Layer
- The layer operator accepts multiple unit specifications to produce a view in which subsequent charts are plotted on top of each other.
- The authors compute the union of the data domains for the x or y channel, for which they then generate a single scale.
- The authors believe this is a useful default for producing coherent and comparable layers.
- Vega-Lite can not enforce that a unioned domain is semantically meaningful.
- Independent scales and guides for each layer produce a dual-axis view, as shown in the layered plots in Fig. 3(a).
3.2.2 Concatenation
- To place views side-by-side, Vega-Lite provides operators for horizontal and vertical concatenation.
- If aligned spatial channels have matching data fields (e.g., the y channels in an hconcat use the same field), a shared scale and axis are used.
- Axis composition facilitates comparison across views and optimizes the underlying implementation.
- Fig. 3(b) concatenates the line chart from Fig. 2(a) with a dot plot, using independent scales.
3.2.3 Facet
- While concatenation allows composition of arbitrary views, one often wants to set up multiple views in a parameterized fashion.
- The facet operator produces a trellis plot [1] by subsetting the data by the distinct values of a field.
- The scale and axis parameters specify how sub-plots are positioned and labeled.
- To facilitate comparison, scales and guides for quantitative fields are shared by default.
- Users can override the default behavior via the resolve component.
3.2.4 Repeat
- The repeat operator generates multiple plots, but unlike facet allows full replication of a data set in each cell.
- Repeat(channel, values, scale, axis, view, resolve) Similar to facet, the channel parameter indicates if plots should divide by row or column, also known as The signature is.
- By default, scales and axes are independent, but legends are shared when data fields coincide.
- Like 1As the repeat operator requires parameterization of the inner view, it is not strictly algebraic.
- The authors believe the current syntax to be more usable and concise than these alternatives.
3.3 Nested Views
- Composition operators can be combined to create more complex nested views or dashboards, with the output of one operator serving as input to a subsequent operator.
- A layer of two unit views might be repeated, and then concatenated with a different unit view.
- The one exception is the layer operator, which, as previously noted, only accepts unit views to ensure consistent plots.
- For concision, two dimensional faceted or repeated layouts can be achieved by applying the operators to the row and column channels simultaneously.
- When faceting a composite view, only the dataset targeted by the operator is partitioned; any other datasets specified in sub-views are replicated.
4 THE VEGA-LITE GRAMMAR OF INTERACTION
- To support specification of interaction techniques, Vega-Lite extends the definition of unit specifications to also include a set of selections.
- Selections identify the set of points a user is interested in manipulating.
- The authors define the components of a selection, describe a series of transforms for modifying selections, and detail how selections can parameterize visual encodings to make them interactive.
4.1 Selection Components
- The authors formally define a selection as an eight-tuple: selection := (name, type, predicate, domain|range, event, init, transforms, resolve) A point selection is backed by a single datum, and its predicate tests for an exact match against properties of this datum.
- Fig. 5(c) demonstrates how mouseover events are used to populate a list selection.
- Doing so populates the selection with the given scales’ domain or range, as appropriate for the selection, and parameterizes the scales to use the selection instead.
4.2 Selection Transforms
- Analogous to data transforms, selection transforms manipulate the components of the selection they are applied to.
- They may perform operations on the backing points, alter a selection’s predicate function, or modify the input events that update the selection.
- In Fig. 5(b), additional points are added to the list selection on shift-click (where click is the default event for list selections).
- If no coordinates are available (e.g., as with keyboard events), an optional by argument should be specified.
- All transforms are first parsed, setting properties on an internal representation of a selection, before they are compiled to produce event handling and interaction logic.
4.3 Selection-Driven Visual Encodings
- Once selections are defined, they parameterize visual encodings to make them interactive — visual encodings are automatically reevaluated as selections change.
- Each data tuple participating in the encoding is evaluated against selection predicates in turn, and visual properties are set corresponding to the first branch that evaluates to true.
- As shown in Fig. 5, the fill color of the scatterplot circles is determined by a data field if they fall within the id selection, or set to grey otherwise.
- By default, this applies a selection’s predicate against the data tuples (or visual elements) of the unit specification it is defined in.
- For multi-view displays, selection names can be specified as the domain or range of a particular channel’s scale.
4.4 Disambiguating Composite Selections
- Selections are defined within unit specifications, providing a default context.
- Several strategies exist for resolving this ambiguity.
- Setting a selection to resolve to independent creates one instance per view, and each unit uses only its own selection to determine inclusion.
- More concretely, with the SPLOM example, these settings would continue to produce one brush per cell, and points would highlight when they lie within at least one brush or if they are within every brush as shown in Fig. 8(c, d).
5 THE VEGA-LITE COMPILER
- The Vega-Lite compiler ingests a JSON specification and outputs a lower-level Reactive Vega specification (also expressed as JSON).
- To overcome these challenges, the compiler generates the output Vega specification in four phases: parse ingests and disambiguates the Vega-Lite specification; build creates the necessary internal representations to map between Vega-Lite and Vega primitives; merge optimizes this representation to remove redundancies; and finally, assemble compiles this representation into a Vega specification.
- If the color channel is mapped to an nominal field, and the user has not specified a scale domain, a categorical color palette is inferred.
- Once the necessary components have been built, the compiler performs a bottom-up traversal of the model tree to merge redundant components.
- Each run-time selection transform (i.e., those that are triggered by an event) generates signals as well, and may augment the selection’s data source with data transformations.
6 EXAMPLE INTERACTIVE VISUALIZATIONS
- Vega-Lite’s design is motivated by two goals: to enable rapid yet expressive specification of interactive visualizations, and to do so with concise primitives that facilitate systematic enumeration and exploration of design variations.
- Such changes to the specification are not mutually exclusive, and can be composed as shown in Fig. 5(e).
- Users can now brush, pan and zoom the scatterplot.
- Moreover, by enabling this interaction through composable primitives (rather than a single, specific “pan and zoom” operator [4]), Vega-Lite also facilitates exploring related interactions in the design space.
- Instead of applying the selection back onto the input dataset, the authors can instead materialize it as an overlay (Fig. 11).
7 DISCUSSION
- The examples demonstrate that Vega-Lite specifications are more concise than those of the lower-level Vega language, and yet are suf- ficiently expressive to cover an interactive visualization taxonomy.
- Nevertheless, the authors identify two classes of limitations that currently exist.
- While their selection abstraction supports interactive linking of marks, their view algebra does not yet provide means of visually linking marks across views (e.g., as in the Domino system [10]).
- By offering a multi-view grammar of graphics tightly integrated with a grammar of interaction, Vega-Lite facilitates rapid exploration of design variations.
Did you find this useful? Give us your feedback
Citations
497 citations
251 citations
Cites methods from "Vega-Lite: A Grammar of Interactive..."
...However, the cited tools use visual grammars that encode data directly to the visual properties of single graphical elements [5]....
[...]
250 citations
Cites background or methods from "Vega-Lite: A Grammar of Interactive..."
...A specification in CompassQL (spec) has a similar structure to a Vega-Lite unit specification [24], but allows replacing concrete values with enumeration specifiers (or “wildcards”), indicating that certain properties should be determined by the query engine....
[...]
..., [24, 34, 35]) can succinctly express a variety of charts, in part by letting users omit design details required by lower-level visualization languages (e....
[...]
...Interactions in Voyager 2 produce specifications in CompassQL, a generalization of the Vega-Lite grammar [24] to support partial view specifications....
[...]
...Both specifications and recommendations in Voyager 2 are represented using CompassQL [38], a visualization query language based on Vega-Lite [24]....
[...]
238 citations
Cites methods from "Vega-Lite: A Grammar of Interactive..."
...We plan to extend the model to transformations such as filtering and sorting, and incorporate Vega-Lite’s interaction primitives [52]....
[...]
...Although the current design space in Draco is limited, as noted above we plan to extend the model further, including interaction primitives such as Vega-Lite selections [52]....
[...]
...Following CompassQL [65], Draco uses a logical representation of the Vega-Lite grammar [52]....
[...]
...We first formulate a simple yet powerful visualization description language based on the Vega-Lite grammar [52] and then extend this language to express dataset and task characteristics....
[...]
171 citations
References
2,550 citations
"Vega-Lite: A Grammar of Interactive..." refers background in this paper
...Moreover, by enabling this interaction through composable primitives (rather than a single, specific “pan and zoom” operator [4]), Vega-Lite also facilitates exploring related interactions in the design space....
[...]
...More expressive lower-level (and thus more verbose) grammars, including those of Protovis [3], D3 [4], and Vega [22], have been widely used for creating explanatory and highly-customized graphics....
[...]
...Low-level grammars such as Protovis [3], D3 [4], and Vega [22] are useful for explanatory data visualization or as a basis for customized analysis tools, as their primitives offer fine-grained control....
[...]
1,545 citations
"Vega-Lite: A Grammar of Interactive..." refers background in this paper
...Voyager leverages perceptual effectiveness criteria [2, 8, 16] to rank candidate visual encodings....
[...]
1,483 citations
1,309 citations
"Vega-Lite: A Grammar of Interactive..." refers background in this paper
...Voyager leverages perceptual effectiveness criteria [2, 8, 16] to rank candidate visual encodings....
[...]
1,018 citations
"Vega-Lite: A Grammar of Interactive..." refers background in this paper
...The selection can also serve as the scale domain for a secondary view, thereby constructing an overview + detail interaction....
[...]
Related Papers (5)
Frequently Asked Questions (10)
Q2. What are the future works in "Vega-lite: a grammar of interactive graphics" ?
One promising avenue for future work is to develop models and techniques to analogously recommend suitable interaction methods for given visualizations and underlying data types.
Q3. What is the function that applies the selection against the backing datasets?
The filterWith data transform applies the selection against the backing datasets such that only data values that fall within the selection are displayed.
Q4. What are the primary features of a low-level grammar?
Low-level grammars such as Protovis [3], D3 [4], and Vega [22] are useful for explanatory data visualization or as a basis for customized analysis tools, as their primitives offer fine-grained control.
Q5. What is the function that offsets the spatial properties of the backing points?
by): Offsets the spatial properties (or corresponding data fields) of backing points by an amount determined by the coordinates of the sequenced events.
Q6. What is the process of merging components?
Once the necessary components have been built, the compiler performs a bottom-up traversal of the model tree to merge redundant components.
Q7. How does Vega-Lite support expressive interaction methods?
To support expressive interaction methods, the authors first contribute an algebra to compose singleview Vega-Lite specifications into multi-view displays using layer, concatenate, facet and repeat operators.
Q8. What is the function that augments the selection’s event processing?
nearest(): Computes a Voronoi decomposition, and augments the selection’s event processing, such that the data value or visual elementnearest the selection’s triggering event is selected (approximating a Bubble Cursor [11]).
Q9. What is the syntax for creating a composite view?
Their formal definitions are instantiated in a JSON (JavaScript Object Notation) syntax, as shown in Fig. 2.Given multiple unit specifications, composite views can be created using a set of composition operators.
Q10. How can you adapt techniques to a different design?
Specifying common techniques can be time-consuming, requiring tens of lines of JSON, and it is difficult to know how to adapt techniques in pursuit of alternative designs.