Published
Edited
May 13, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chart = {
let svg = Plot.lineY(data, Plot.binX({y: "sum" },{
x: "time",
y: "value",
thresholds: d3.timeWeek
})).plot({ grid: true, marginLeft: 80 })
return svg
}
Insert cell
Insert cell
Plot.rectY(data, Plot.binX({y: "sum" }, {
x: "time",
y: "value",
fill: "checkpoint",
thresholds: d3.timeWeek
})).plot({ grid: true, marginLeft: 80 })
Insert cell
Insert cell
Plot.barX(data, Plot.groupY({x: "sum" }, {
x:"value",
y: "checkpoint",
fill: "checkpoint"
})).plot({
marginLeft: 150,
grid: true
})
Insert cell
Insert cell
Plot.areaY(data, Plot.stackY(Plot.binX({y: "sum" },{
x: "time",
y: "value",
fill: "checkpoint",
offset: "silhouette",
thresholds: d3.timeWeek
}))).plot({ grid: true, marginLeft: 100 })
Insert cell
Insert cell
Plot.barY(data, Plot.stackY(Plot.binX({y: "sum" },{
x: "time",
y: "value",
fill: "checkpoint",
offset: "silhouette",
thresholds: d3.timeMonth
}))).plot({
grid: true,
x: {
tickRotate: 90,
tickFormat: d => Plot.formatMonth()(d.getMonth()) + " " + d.getFullYear()
},
marginBottom: 100,
marginLeft: 100
})
Insert cell
Insert cell
Plot.barX(data, Plot.groupY({x: "sum" }, { x:"value", y: "checkpoint", fill: "checkpoint" })).plot({
marginLeft: 50,
facet: {
data,
x: d => d.time.getFullYear()
},
grid: true,
width
})
Insert cell
Insert cell
Plot.barX(data, Plot.stackY(Plot.groupY({x: "sum" }, {
x:"value",
y: "checkpoint",
fill: "checkpoint"
}))).plot({
marginLeft: 50,
facet: {
data,
y: d => d.time.getFullYear()
},
y: { axis: false },
grid: true
})
Insert cell
Insert cell
Plot.barY(data, Plot.groupX({y: "sum" }, {
y:"value",
x: d => d.time.getMonth()
})).plot({
marginLeft: 100,
facet: {
data,
y: d => d.time.getFullYear()
},
marks: [ Plot.frame({ stroke: "#aaa" }) ],
x: { tickFormat: Plot.formatMonth(), grid: true }
})
Insert cell
Insert cell
Plot.line(data, { x: "time", y: "value", stroke: "checkpoint" }).plot({ marginLeft: 100})
Insert cell
Insert cell
// this plots rolling average over last 7 days
Plot.line(data, Plot.windowY({ x: "time", y: "value", stroke: "checkpoint", k: 7 })).plot({ marginLeft: 100})
Insert cell
Insert cell
Insert cell
// data = d3.csv(url)
data = tidy(
await d3.csv(url),
pivotLonger({ cols: ['-Time','-Date','-Hour','-Total'], namesTo: 'checkpoint', valuesTo: 'value' }),
mutate({
time: d => d.Hour ? new Date(d.Date + "T" + d.Hour) : new Date(d.Date),
value: d => +d.value
})
).filter(d => d.time.getFullYear() > 2018)
Insert cell
Inputs.Table(data)
Insert cell
url = `https://raw.githubusercontent.com/mikelor/TsaThroughput/main/data/processed/tsa/throughput/TsaThroughput.${airport}.csv`
Insert cell
d3.extent(data, d => d.Date)
Insert cell
Insert cell
import {
tidy,
pivotLonger,
groupBy,
mutate,
distinct,
map,
summarize,
mean,
total
} from '@pbeshai/tidyjs'
Insert cell
d3 = require("d3@6")
Insert cell
Inputs = require("@observablehq/inputs@0.7")
Insert cell
Plot = require("@observablehq/plot@0.1")
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