Published
Edited
Apr 26, 2021
2 stars
Insert cell
Insert cell
Insert cell
dataGroupedByYearContinent = d3.group(data, d => d.year, d => d.continent)
Insert cell
years = [...new Set(dataGroupedByYearContinent.keys())]
Insert cell
continents = [...new Set(dataGroupedByYearContinent.get(years[0]).keys())]
Insert cell
sliderSteps = years.map((y, i) => ({
method: "animate",
label: y,
args: [
[y],
{
mode: "immediate",
transition: { duration: 300 },
frame: { duration: 300, redraw: false }
}
]
}))
Insert cell
traces = frames[0].data
Insert cell
frames = years.map((y, i) => ({
name: y,
data: continents.map((continent) => lookup[y][continent])
}))
Insert cell
Insert cell
data = d3.csv(
"https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv",
d3.autoType
)
Insert cell
md`### External libraries and imports`
Insert cell
d3 = require("d3@6")
Insert cell
Plotly = require("plotly.js-dist")
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