Avenger is an early stage prototype of a new foundational rendering library and visualization primitives for information visualization (InfoVis) systems. Avenger defines a 2D scenegraph representation tailored to the needs of InfoVis systems, along with visualization primitives like scales and guides. And an event stream system for interactive visualizations inspired by Vega.
Avenger is written in Rust, and may be used directly from Rust.
For example, to launch a wgpu rendered visualization in a native window, run the following example:
cd examples/iris-pan-zoom
cargo run --release
Avenger may be compiled to WASM with rendering performed in WebGPU or WebGL2 (If WebGPU is not supported by the browser)
To build the example above to WASM, run the following:
cd examples/iris-pan-zoom
wasm-pack build --target web --release
Then open examples/iris-pan-zoom/index.html
in a web browser.
The PngCanvas
struct can be used to convert a scene graph to a PNG image headlessly. See the tests in
avenger-wgpu/tests/test_image_baselines.rs for usage.
Avenger's core is written in Rust and is composed of the following crates:
avenger-app
: Application framework for building interactive Avenger-based visualizationsavenger-common
: Shared types and utilities for the Avenger visualization systemavenger-eventstream
: Interactive event handling system for Avenger visualizationsavenger-geometry
: Geometry processing and spatial indexing for Avenger scene graphsavenger-guides
: Visualization guide generation for Avenger (axes, legends, colorbars)avenger-image
: Image loading and processing for the Avenger rendering systemavenger-scales
: High-performance data visualization scales with mappings between data domains and visual rangesavenger-scenegraph
: The coreSceneGraph
representation that is independent of rendering backendavenger-text
: Text measurement and rasterization for the Avenger rendering systemavenger-vega-scenegraph
: Logic to construct an AvengerSceneGraph
from a Vega scenegraphavenger-vega-test-data
: Crate that uses vl-convert to generate test data. For each baseline vega spec,avenger-vega-test-data
will write out a vega scenegraph in JSON format along with a PNG rendering of the chart (which uses resvg). The tests in avenger-wgpu/tests/test_image_baselines.rs then input the scenegraph, render to PNG withavenger-wgpu
, and compare the results to the baselines using structural similarityavenger-wgpu
: Logic to render an AvengerSceneGraph
using wgpuavenger-winit-wgpu
: Native window application runner for interactive Avenger visualizations
This is a hobby project with large ambitions. Where it goes will largely depend on whether other people get involved. But here are a few potential directions.
- Serverside rendering of select marks with VegaFusion: VegaFusion performs deep analysis of Vega specifications to optimize then and pre-evaluate data transformations in the Python kernel. This logic could be extended to include pre-rendering select marks using Avenger. This provides the benefit of sending only a png image to the browser rather than the full input dataset. Work would be needed to figure out how to support interactivity in this scenario.
- Vega native: Combining Avenger and VegaFusion gets us close to being able to render entire Vega visualizations without JavaScript. More thought is needed, but it may make sense to add support for scales and guides (axes, legends, colorbars, etc.) to the Avenger SceneGraph. Then VegaFusion could have a mode that produces an Avenger scenegraph for rendering. To support interactive charts, Avenger could adopt Vega's Event Stream system (https://vega.github.io/vega/docs/event-streams/).
- Matplotlib backend: Avenger could potentially serve as a rendering backend for Matplotlib (as an alternative to Agg) that provides GPU acceleration. See https://matplotlib.org/stable/users/explain/figure/backends.html#the-builtin-backends.
- CPU rendering: The wgpu backend requires GPU support, so it would be useful to have a CPU rendering option as well. This could be based on tinyskia, which is what resvg uses.
- SVG/PDF rendering: Renderers that produce SVG and PDF documents from the Avenger SceneGraph could be written.
Do any of the ambitions above sound interesting? Are you interested in learning Rust? Please start a discussion and get involved.