Notable Changes
-
Improved Streaming Performance.
For performance, Vega caches a lot of internal data structures, including calculated tuples, scenegraph items, and SVG DOM nodes. Previously, nested scopes (such as those created for facetted data) that result in vega-runtime subcontexts were never cleaned. If no external View API calls are made, this is fine, and actually improves performance for interaction-driven dynamic filtering. However, when providing streaming data to Vega through the View API, uncleaned caches and subcontexts can result in substantial memory leaks that also eventually degrade performance.
This version adds mechanisms for clearing caches and detaching subflows to support streaming data within nested specifications. When input data is removed via a View API call or via signal-valued URL, Vega will now by default trigger garbage collection to reclaim resources. This behavior can be disabled by calling
clean(false)
on a constructed ChangeSet passed to the View API. -
Improved Cursor Performance.
Previously Vega updated the
cursor
style on the HTML document body. This persists cursor settings even during interactions (such as drags) that may leave the Vega View component. However, it also can result in large performance penalties in Chrome, which re-evaluates CSS styles in response. This version changes the default behavior to set the cursor locally on the Vega View component. If a global cursor is desired, the boolean config propertyevents.globalCursor
can be settrue
or the View methodglobalCursor
can be invoked to change the setting at runtime. -
Optional Expression Interpreter.
This release adds interpreter support for Vega expressions that is Content Security Policy (CSP) compliant. By default, the Vega parser performs code generation for parsed Vega expressions, and the Vega runtime uses the Function constructor to create JavaScript functions from the generated code. Although the Vega parser includes its own security checks, the runtime generation of functions from source code nevertheless violates security policies designed to prevent cross-site scripting.
This release provides an interpreter plug-in (the new
vega-interpreter
package) that evaluates expressions by traversing an Abstract Syntax Tree (AST) for an expression and performing each operation in turn. Use of the interpreter enables compliance with CSP, but can incur a performance penalty. In tests of initial parse and dataflow evaluation times, the interpreter is on average ~10% slower. Interactive updates may incur higher penalties, as they are often more expression-heavy and amortize the one-time cost of Function constructor parsing.
Changelog
Changes from v5.12.3:
vega
- Update
stream.html
andstream-nested.html
performance test pages.
vega-dataflow
- Add
detach
method toOperator
to remove adjacent edges (listeners) from the dataflow graph. - Add
clean
setter toChangeSet
, set totrue
by default if any tuples are removed. - Add
clean
getter/setter to Pulse, propagate value to forked pulses if they share a datasource
. - Update logging calls during Dataflow evaluation.
vega-encode
- Update
DataJoin
transform to clean internal map whenpulse.clean()
is true. - Update
Scale
to includedomainMid
as an extrema if it exceeds the domain min or max. (#2656)
vega-functions
- Fix scale function to not special case
undefined
input. This ensures identical semantics with the internal_scale
helper function used by code-generated encoders.
vega-geo
- Update d3-geo dependency.
vega-interpreter
- Add new vega-interpreter package.
vega-projection
- Update d3-geo dependency.
vega-projection-extended
- Update vega-projection dependency.
vega-runtime
- Add runtime
detach
method to remove subcontexts. Export asdetachSubflow
on the head operator of a generated subflow. - Add pluggable expression evaluators.
vega-statistics
- Fix
numbers
utility to exclude empty string.
vega-transforms
- Update
Aggregate
transform to clean internal map whenpulse.clean()
is true. - Update
Facet
,PreFacet
, andSubflow
transforms to prune subflows in response topulse.clean()
. - Update
Load
transform to setpulse.clean(true)
when removing loaded data. - Fix
Bin
andExtent
to treat empty string as a missing value. (thanks @domoritz!) - Fix aggregate ops to treat empty string as a missing value.
vega-typings
- Add
eventConfig.globalCursor
to config typings. - Add dataflow logger to typings.
- Add parse options to typings.
vega-util
- Refactor code for
fastmap
andvisitArray
utilities.
vega-view
- Add View constructor option
expr
to pass in a custom expression evaluator. - Add
globalCursor
method and event configuration. - Update to make the Vega view container the default cursor target.