I am able to get vega json grammar on local installation of nodejs with vega-lite
and vega-lite-api
installed through npm
as follows:
vl = require('vega-lite')
vla = require('vega-lite-api')
data = require('vega-datasets')
const df2 = data['movies.json']()
const plot = vla.markBar().data(df2).encode(
vla.x().fieldQ('IMDB_Rating').bin(true),
vla.y().count()
)
vega_lite_json = plot.toObject();
vega_json = vl.compile(plot.toObject()).spec;
However I am unable to make it work in Observablehq.
I am not able to do last line: vl.compile(...)
.
This is what I have did:
vegalite = require("@observablehq/[email protected]")
vegalite.compile(plot.toObject()).spec;
It says: TypeError: vegalite.compile is not a function
Here is link to my observablehq notebook cell executing vegalie.compile(...)
.
What I am doing wrong?