Public
Edited
Apr 3, 2023
Insert cell
Insert cell
+d[0].Year.slice(0, 4)
Insert cell
// year_range = d3.extent(d, x => +x.Year.slice(0, 4))
year_range = [1970, 1982]
Insert cell
viewof year = Inputs.range(year_range, {value: year_range[0], step: 1, label: "Min. Year"})
Insert cell
viewof color = Inputs.radio(["Year", "Origin", "Cylinders"], {label: "Color by", value: "Origin"})
Insert cell
plot = Plot.plot({
marks: [
// Plot.dot(d.filter(x => +x.Year.slice(0, 4) > year), {x: "Horsepower", y: "Displacement", stroke: color})
Plot.dot(d, {x: "Horsepower", y: "Displacement", stroke: color})
]
})
Insert cell
d.filter(x => x.Year.slice(0, 4) > year)
Insert cell
Insert cell
jsonURL = `/api/${year}/`
// jsonURL = data['cars.json'].url
Insert cell
d = fetch(jsonURL).then(response => {
if (!response.ok) throw new Error(response.status);
return response.json();
})
// d = data['cars.json']()
Insert cell
x = fetch(jsonURL)
.then(response => {
if (!response.ok) throw new Error(response.status);
return response.json();
})
Insert cell
data = require('vega-datasets@2')
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