diff --git a/src/App.jsx b/src/App.jsx
index 7f357eb..5bda430 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -329,7 +329,7 @@ function App() {
setChartError(false);
}, [selectedStudent]);
- // FIXED PRINT FUNCTION - THE KEY CHANGE IS HERE
+ // FIXED PRINT FUNCTION
const handlePrintResult = useCallback(() => {
if (!selectedStudent) return;
@@ -490,11 +490,10 @@ function App() {
printWindow.document.write(printContent);
printWindow.document.close();
- // FIXED: Removed the printWindow.close() call that was causing the issue
// Wait for the document to load before printing
printWindow.onload = function() {
printWindow.print();
- // DO NOT CLOSE THE WINDOW - Let the user close it when they're done
+ // Do not close the window - let the user close it when they're done
};
}, [selectedStudent]);
@@ -724,34 +723,20 @@ function App() {
}
}, [cgpaTrendData]);
- // Prepare data for CGPA Distribution Bar Chart
+ // FIXED CGPA Distribution with cumulative counts
const cgpaDistributionData = useMemo(() => {
- const thresholds = [2.5, 3.0, 3.25, 3.5, 3.75, 3.8, 3.9, 4.0];
- const distribution = [];
+ const thresholds = [2.5, 3.0, 3.25, 3.5, 3.75, 3.8, 3.9];
- for (let i = 0; i < thresholds.length; i++) {
- const lowerBound = thresholds[i];
- const upperBound = (i + 1 < thresholds.length) ? thresholds[i + 1] : 4.01; // Upper bound for the last range
- const studentsInThreshold = studentData.filter(student =>
- student.cgpa >= lowerBound && student.cgpa < upperBound
- );
+ return thresholds.map(threshold => {
+ const studentsAboveThreshold = studentData.filter(student => student.cgpa > threshold);
- let label;
- if (i + 1 < thresholds.length) {
- label = `${lowerBound.toFixed(2)} - < ${upperBound.toFixed(2)}`;
- } else {
- label = `≥ ${lowerBound.toFixed(2)}`; // For the last category (e.g., >= 4.0)
- }
-
- distribution.push({
- threshold: lowerBound.toFixed(2), // Use lower bound for X-axis tick
- rangeLabel: label, // Full range label for tooltip
- count: studentsInThreshold.length,
- students: studentsInThreshold.map(s => ({ name: s.name, roll: s.roll }))
- });
- }
-
- return distribution;
+ return {
+ range: threshold.toFixed(2),
+ rangeLabel: `>${threshold.toFixed(2)}`,
+ count: studentsAboveThreshold.length,
+ students: studentsAboveThreshold.map(s => ({ name: s.name, roll: s.roll }))
+ };
+ });
}, []);
// Calculate overall statistics
@@ -792,43 +777,55 @@ function App() {