Public
Edited
Aug 26, 2022
Insert cell
# Charter Enrollment
Insert cell
Plot.plot({
y: {
grid: true,
tickFormat: "2s",
nice: true
},
x: {
nice: true,
label: "year"
},
marks: [
Plot.line(
charter_demo.filter((d) => d.network === "Charter" && d.race === "Total"),
{
x: (d) => new Date(d.year.toString()),
y: "count"
}
)
]
})
Insert cell
Plot.plot({
y: {
grid: true,
tickFormat: "%",
nice: true
},
x: {
nice: true,
label: "year"
},
marks: [
Plot.line(market_share, {
x: (d) => new Date(d.year.toString()),
y: "share"
})
]
})
Insert cell
Plot.plot({
y: {
grid: true,
tickFormat: "2s",
nice: true
},
x: {
nice: true,
label: "year"
},
marks: [
Plot.line(
k12
.filter((d) => d.race === "Total")
.map((d) => ({
...d,
count:
d.count -
charter_demo.find((e) => e.race === d.race && e.year === d.year)
?.count
})),
{
x: (d) => new Date(d.year.toString()),
y: "count"
}
),
Plot.line(
k12.filter((d) => d.race === "Total"),
{
x: (d) => new Date(d.year.toString()),
y: "count"
}
)
]
})
Insert cell
k12
.filter((d) => d.race === "African American")
.map((d) => ({
...d,
count:
d.count -
charter_demo.find((e) => e.race === d.race && e.year === d.year)?.count
}))
Insert cell
market_share = charter_demo
.filter((d) => d.network === "Charter" && d.race === "African American")
.map((d) => ({
...d,
share:
d.count / k12.find((e) => e.race === d.race && e.year === d.year).count
}))
Insert cell
k12 = d3
.flatRollup(
demo_grade.filter((d) =>
new Set([
...d3.range(0, 13),
"Full-Day Kindergarten",
"Half-Day Kindergarten"
]).has(d.grade)
),
(v) => d3.sum(v, (d) => d.count),
(d) => d.year,
(d) =>
new Set(["African American", "Hispanic", "white", "Total"]).has(d.race)
? d.race
: "other"
)
.map(([year, race, count]) => ({ year, race, count }))
Insert cell
demo_grade = d3.csv(
"https://docs.google.com/spreadsheets/d/e/2PACX-1vSlDJgyBRmDGBdhVi_fWU6bxprkLZrKrW2YNvGW1hVToXRz9kWQvAPM2UVh28sGMjqfL_1nBNUrjHbl/pub?gid=1346209997&single=true&output=csv",
d3.autoType
)
Insert cell
charter_demo = d3.csv(
"https://docs.google.com/spreadsheets/d/e/2PACX-1vT7TTZ2KVkhokxI6pB-IR5DHHSx4MHJuppqQvTe5c6wMJHsOCQOdpWEEfH55XwWWtqevn0fMAuhfLHH/pub?gid=0&single=true&output=csv",
d3.autoType
)
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