Conversion Overrides#
An override changes one conversion without affecting the converter configuration. Use Configuration instead when the same value should apply to every conversion.
Override |
Applies to |
Effect |
|---|---|---|
|
Vega-Lite |
Applies a built-in or custom theme |
|
Vega-Lite and Vega |
Merges a Vega or Vega-Lite configuration object into the input |
|
Vega-Lite and Vega |
Selects number formatting rules |
|
Vega-Lite and Vega |
Selects date and time formatting rules |
|
Vega-Lite and Vega |
Sets the chart background and logical size before rendering |
|
PNG and JPEG |
Multiplies raster pixel dimensions |
|
PNG |
Combines with |
|
JPEG |
Sets encoding quality from |
|
SVG and HTML |
Embeds fonts and images in SVG, or browser dependencies in HTML |
|
HTML |
Selects |
|
Vega-Lite |
Selects a bundled Vega-Lite compiler version |
|
Vega-Lite and Vega |
Makes selected Google Fonts available to one conversion |
|
Vega-Lite and Vega |
Registers plugin code for one conversion |
|
Vega Editor URLs |
Selects the full-screen editor URL form |
SVG input conversions accept only the raster options scale, ppi, and quality. Chart options such as theme, width, and height do not apply to them.
The examples override this Vega-Lite input:
chart.vl.json
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"data": {
"values": [
{"category": "A", "value": 28},
{"category": "B", "value": 55},
{"category": "C", "value": 43},
{"category": "D", "value": 91},
{"category": "E", "value": 81}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "category", "type": "nominal"},
"y": {"field": "value", "type": "quantitative"}
}
}
Put chart options in VlOpts or VgOpts and format options in an output type such as PngOpts or HtmlOpts:
use vl_convert_rs::{PngOpts, VlConverter, VlOpts};
let spec = std::fs::read_to_string("chart.vl.json")?;
let converter = VlConverter::new();
let output = converter
.vegalite_to_png(
spec,
VlOpts {
width: Some(640.0),
height: Some(360.0),
theme: Some("dark".to_string()),
..Default::default()
},
PngOpts {
scale: Some(2.0),
..Default::default()
},
)
.await?;
std::fs::write("chart.png", output.data)?;
A per-call plugin also requires allow_per_request_plugins: true in VlcConfig. See Enable Per-Request Plugins.
Font inspection takes FontOpts as the third argument to vegalite_fonts() or vega_fonts(). These options apply to one call and do not inherit VlcConfig. See Font Introspection.