Public
Edited
Jul 4, 2024
1 fork
Insert cell
Insert cell
viewof playButton = Inputs.button("Play")
Insert cell
viewof chart = vegaEmbed(startSpec, {renderer: "svg"})
Insert cell
{
if (playButton) animation.play(".chart-wrapper");
}
Insert cell
animation = gemini.animate(startSpec, endSpec, gemSpec)
Insert cell
gemSpec = ({
timeline: {
sync: [
{component: {axis: "x"}, timing: {duration: 1000}},
{component: {mark: "marks"}, timing: {duration: 1000}}
]
}
})
Insert cell
startSpec = gemini.vl2vg4gemini({
data: { values: [{"Hungry": 50, "Name": "Gemini"}, {"Hungry": 100, "Name": "Cordelia"}] },
mark: "bar",
encoding: {
x: { field: "Hungry", type: "quantitative"},
y: { field: "Name", type: "nominal"}
}
})
Insert cell
endSpec = gemini.vl2vg4gemini({
data: { values: [{"Hungry": 100, "Name": "Gemini"}, {"Hungry": 80, "Name": "Cordelia"}] },
mark: "bar",
encoding: {
x: { field: "Hungry", type: "quantitative"},
y: { field: "Name", type: "nominal"}
}
})
Insert cell
Insert cell
d3 = require('d3@5.14.2')
Insert cell
gemini = require("https://cdn.jsdelivr.net/gh/declann/gemini@1c2e679/gemini.web.js") // pinned
Insert cell
vegaEmbed = require("https://cdn.jsdelivr.net/gh/declann/vega-embed-vl4@main/build/vega-embed.js")
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