Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 3x 3x 1x 3x 7x 47x 47x 7x 47x 112x 3x 6x 6x 2256x 2256x 2256x 1422x 834x 6x 435x 435x 47x 435x 6x | const allGrades = [
"A+",
"A",
"A-",
"B+",
"B",
"B-",
"C+",
"C",
"C-",
"D+",
"D",
"D-",
"F",
"P",
"W",
"NP",
];
export const formatTooltip = (value, _, props) => {
return [`Percentage: ${value.toFixed(1)}%, Count: ${props.payload.count}`];
};
// Helper function to fill in for when 0 students got a grade
export const createCompleteGradeData = (data) => {
const gradeCounts = data.reduce((acc, item) => {
acc[item.grade] = item.count;
return acc;
}, {});
const totalCount = Object.values(gradeCounts).reduce(
(acc, count) => acc + count,
0,
);
return allGrades.map((grade) => ({
grade,
count: gradeCounts[grade] || 0,
percentage:
totalCount > 0 ? ((gradeCounts[grade] || 0) / totalCount) * 100 : 0,
}));
};
// Helper function to group data by `yyyyq` and `instructor`
// This will allow different instructors in the same quarter to be displayed seperatly
export const groupDataByQuarterAndInstructor = (data) => {
const groupedData = {};
// Added sort function to be able to display data by most recent quarter
data.sort((a, b) => {
const [yearA, qtrA] = [a.yyyyq.slice(0, 4), a.yyyyq[4]];
const [yearB, qtrB] = [b.yyyyq.slice(0, 4), b.yyyyq[4]];
if (yearA !== yearB) {
return yearB - yearA;
} else {
return qtrB - qtrA;
}
});
data.forEach((item) => {
const key = `${item.yyyyq}-${item.instructor}`;
if (!groupedData[key]) {
groupedData[key] = [];
}
groupedData[key].push(item);
});
return groupedData;
};
|