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() { - + (index === 0 ? '' : value.toFixed(2))} - tickMargin={8} - angle={-90} - textAnchor="end" - dx={-5} - dy={5} + tickFormatter={(value) => value.toFixed(2)} + tickMargin={10} + tick={{ fontSize: 12, fill: '#666' }} + axisLine={{ stroke: '#ccc' }} + tickLine={{ stroke: '#ccc' }} + /> + + - - @@ -842,7 +839,7 @@ function App() { ); } - }, [selectedStudentGpaTrendData, selectedStudentGpaDomain, isMobile, chartError]); + }, [selectedStudentGpaTrendData, selectedStudentGpaDomain, chartError]); return (
@@ -899,7 +896,7 @@ function App() { {searchTerm.trim() !== '' && filteredStudents.length === 0 && (
- No students found matching "{searchTerm}". Please try a different name or roll. + No students found matching "${searchTerm}". Please try a different name or roll.
)}
@@ -976,7 +973,7 @@ function App() { -
+

{selectedStudent.name ? `${selectedStudent.name}'s GPA Trend` : "Student's GPA Trend"}

@@ -1007,48 +1004,60 @@ function App() { {/* Overall Charts - Now 50/50 split */}
{/* Overall Average GPA Trend by Semester */} -
+

Overall Average GPA Trend by Semester

- + (index === 0 ? '' : value.toFixed(2))} - tickMargin={8} - angle={-90} - textAnchor="end" - dx={-5} - dy={5} + tickFormatter={(value) => value.toFixed(2)} + tickMargin={10} + tick={{ fontSize: 12, fill: '#666' }} + axisLine={{ stroke: '#ccc' }} + tickLine={{ stroke: '#ccc' }} + /> + + - - @@ -1056,20 +1065,49 @@ function App() {
{/* CGPA Distribution (Number of Students) */} -
+

CGPA Distribution (Number of Students)

- - - + + + } /> - - + +