Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vl #501

Merged
merged 4 commits into from
Jan 11, 2024
Merged

vl #501

merged 4 commits into from
Jan 11, 2024

Conversation

mbostock
Copy link
Member

Adds the vega-lite-api to recommended libraries as vl. The equivalent JavaScript is:

import * as vega from "npm:vega";
import * as vegaLite from "npm:vega-lite";
import * as vegaLiteApi from "npm:vega-lite-api";

const vl = vegaLiteApi.register(vega, vegaLite);

@mbostock mbostock requested a review from Fil January 11, 2024 16:42
@mbostock
Copy link
Member Author

This ends up loading two versions of vega 😞 because [email protected] loads [email protected], whereas loading the latest version gives [email protected]. I can’t tell why that is, though… it seems to be that jsDelivr is stale in resolving the version of the vega peer dependency from vega-lite. Anyway, I think this PR is correct.

@Fil
Copy link
Contributor

Fil commented Jan 11, 2024

Nice! and, to consume a JSON spec, we can do this:

```js
function vlFromSpec(spec) {
  const div = document.createElement("div");
  const view = div.value = new vl.vega.View(vl.vega.parse(vl.vegalite.compile(spec).spec));
  return view.initialize(div).runAsync().then(() => div);
}
```

```js
display(vlFromSpec({ … spec …})
```

@Fil
Copy link
Contributor

Fil commented Jan 11, 2024

I wonder if we should expose an additional method to render from a JSON spec like I did above; but maybe there is already something in this vl object that does it and that I'm not seeing.

@mbostock
Copy link
Member Author

I guess we should add vega-tooltip as a dependency… 🤔

@mbostock mbostock enabled auto-merge (squash) January 11, 2024 18:20
@mbostock mbostock merged commit f5580e1 into main Jan 11, 2024
2 checks passed
@mbostock mbostock deleted the mbostock/vega-lite branch January 11, 2024 18:20
cinxmo pushed a commit that referenced this pull request Jan 12, 2024
* vl

* add vega-lite preloads

* more documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants