Public
Edited
Jul 23, 2024
Insert cell
Insert cell
Insert cell
csvdata = (async () => {
const response = await fetch(
"https://data.cityofnewyork.us/resource/c3uy-2p5r.csv"
);
return await response.text();
})()
Insert cell
airquality = d3.csvParse(csvdata)
Insert cell
airquality
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
airquality
X
name
Y
mean
data_value
Color
Size
Facet X
Facet Y
Mark
bar
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.barY(
airquality,
Plot.groupX(
{
y: "mean",
title: (d) =>
`Mean air quality: ${(
d.reduce((acc, curr) => acc + curr.data_value, 0) / d.length
).toFixed(0)} \n Air particle: ${d[0].name}`
},
{
x: "name",
y: "data_value"
}
)
),
Plot.ruleY([0])
]
})
Insert cell
Plot.plot({
marks: [
Plot.barY(airquality, {
x: "name",
y: "data_value",
sort: { x: "y", reverse: true },
title: "data_value"
}),
Plot.ruleY([0])
],
y: {
grid: true
},
marginLeft: 50,
marginTop: 50,
marginBottom: 50
})
Insert cell
Insert cell
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
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