Public
Edited
May 18, 2023
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
function printVegaLiteJSON(plot, includeData = false){
let plotObject = plot.toObject();
if(includeData === false){
if(plotObject.hasOwnProperty('data')){
plotObject.data = "Data removed for printing to Observable";
}
if(plotObject.hasOwnProperty('spec')){
plotObject.spec.data = "Data removed for printing to Observable";
}

if(plotObject.hasOwnProperty('transform')){
for (const item of plotObject.transform){
if(item.hasOwnProperty('from') && item.from.hasOwnProperty('data')){
item.from.data = "Data removed for printing to Observable";
}
}
}
}
return html`<pre>${JSON.stringify(plotObject, 0, 2)}</pre>`; // format JSON data
}
Insert cell
Insert cell
vegalite = {
const v = window.vega = await require("vega@5");
const vl = window.vl = await require("vega-lite@5");
const ve = await require("vega-embed@6");
async function vega(spec, options) {
const div = document.createElement("div");
div.value = (await ve(div, spec, {...options, mode: 'vega-lite', actions: false})).view;
return div;
}
vega.changeset = v.changeset;
return vega;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more