Skip to content

Commit

Permalink
Set baseURL to support "data/movies.json" style URLs (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease authored Sep 13, 2023
1 parent f02da92 commit 2ecec47
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vl-convert-rs/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ import('{url}').then((sg) => {{
let function_str = r#"
function vegaToSvg(vgSpec) {
let runtime = vega.parse(vgSpec);
let view = new vega.View(runtime, {renderer: 'none'});
const baseURL = 'https://vega.github.io/vega-datasets/';
const loader = vega.loader({ mode: 'http', baseURL });
let view = new vega.View(runtime, {renderer: 'none', loader});
let svgPromise = view.toSVG();
return svgPromise
}
Expand Down
2 changes: 2 additions & 0 deletions vl-convert-rs/tests/test_specs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ mod test_svg {
fn test(
#[values(
"circle_binned",
"circle_binned_base_url",
"stacked_bar_h",
"bar_chart_trellis_compact",
"line_with_log_scale",
Expand Down Expand Up @@ -314,6 +315,7 @@ mod test_png_no_theme {

#[rstest(name, scale,
case("circle_binned", 1.0),
case("circle_binned_base_url", 1.0),
case("stacked_bar_h", 2.0),
case("bar_chart_trellis_compact", 2.0),
case("line_with_log_scale", 2.0),
Expand Down
16 changes: 16 additions & 0 deletions vl-convert-rs/tests/vl-specs/circle_binned_base_url.vl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"url": "data/movies.json"},
"mark": "circle",
"encoding": {
"x": {
"bin": {"maxbins": 10},
"field": "IMDB Rating"
},
"y": {
"bin": {"maxbins": 10},
"field": "Rotten Tomatoes Rating"
},
"size": {"aggregate": "count"}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2ecec47

Please sign in to comment.