Published
Edited
Dec 7, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
getAveragesForGrade = (grade, allCount) => {
let years = [2013, 2014, 2015, 2016, 2017];
let averages = [
[],
[],
[]
];
years.forEach((year) => {
let always = [],
added = [],
dropped = [];
Object.keys(padres_always).forEach((school) => {
always.push(studentsInGrade(padres_always, school, grade, year));
});
Object.keys(padres_added).forEach((school) => {
added.push(studentsInGrade(padres_added, school, grade, year));
});
Object.keys(padres_dropped).forEach((school) => {
dropped.push(studentsInGrade(padres_dropped, school, grade, year));
});
averages[0].push(averageOf(always, allCount));
averages[1].push(averageOf(added, allCount));
averages[2].push(averageOf(dropped, allCount));
});
return averages;
}
Insert cell
Insert cell
grade1data = getAveragesForGrade(1);
Insert cell
c3({
data: {
x: "Year",
columns: [
["Year", 2013, 2014, 2015, 2016, 2017],
["Always"].concat(grade1data[0]),
["Added"].concat(grade1data[1]),
["Dropped"].concat(grade1data[2])
]
}
})
Insert cell
Insert cell
Insert cell
c3({
data: {
x: "Year",
columns: [
["Year", 2013, 2014, 2015, 2016, 2017],
["Always"].concat(grade1bdata[0]),
["Added"].concat(grade1bdata[1]),
["Dropped"].concat(grade1bdata[2])
]
}
})
Insert cell
Insert cell
grade2data = getAveragesForGrade(2, true);
Insert cell
Insert cell
grade3data = getAveragesForGrade(3, true);
Insert cell
Insert cell
grade4data = getAveragesForGrade(4, true);
Insert cell
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