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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more