Published
Edited
Feb 17, 2022
1 star
Insert cell
# Vega Dataflow Serialization Experiment

Learn more about [how Vega works here](https://observablehq.com/@vega/how-vega-works).
Insert cell
vega = require("vega")
Insert cell
Insert cell
Insert cell
dataflowSpec = vega.parse(inputSpec, { ast: true })
Insert cell
view1 = new vega.View(dataflowSpec)
Insert cell
{
const div = document.createElement("div");
div.value = view1.initialize(div).run();
return div;
}
Insert cell
Insert cell
serialized = JSON.stringify(dataflowSpec)
Insert cell
deserialized = JSON.parse(serialized)
Insert cell
view2 = new vega.View(deserialized)
Insert cell
{
const div = document.createElement("div");
div.value = view2.initialize(div).run();
return div;
}
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