jvl is a tiny helper function for embedding vega-lite charts in Jupyter notebooks that are using the IJavaScript kernel.
Install Jupyter and the IJavascript kernel - see instructions here.
In your project folder:
npm init -y
npm install --save jvl
jupyter lab
In your notebook:
const {jvl} = require('jvl')
To print a vega-lite chart simply pass a vega-lite spec to jvl()
:
const spec = {
data: {
values: [
{a: "A", b: 28}, {a: "B", b: 55}, {a: "C", b: 43},
{a: "D", b: 91}, {a: "E", b: 81}, {a: "F", b: 53},
{a: "G", b: 19}, {a: "H", b: 87}, {a: "I", b: 52}
]
},
mark: "bar",
encoding: {
x: {field: "a", type: "ordinal"},
y: {field: "b", type: "quantitative"}
}
}
jvl(spec)