From 09ba8cc9926d449d47ffc0faf668dfd07ac622a4 Mon Sep 17 00:00:00 2001 From: ectasy663 Date: Fri, 25 Sep 2026 16:27:24 +0530 Subject: [PATCH] Update college predictor graph to look like a control chart --- .../ai-coach/college-predictor/page.tsx | 129 +++++++++++------- 1 file changed, 78 insertions(+), 51 deletions(-) diff --git a/src/app/dashboard/ai-coach/college-predictor/page.tsx b/src/app/dashboard/ai-coach/college-predictor/page.tsx index 81e0514..3c10f3d 100644 --- a/src/app/dashboard/ai-coach/college-predictor/page.tsx +++ b/src/app/dashboard/ai-coach/college-predictor/page.tsx @@ -3,54 +3,54 @@ import { useState, useEffect } from "react" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { GraduationCap, BrainCircuit, LineChart as LineChartIcon } from "lucide-react" -import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts' +import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, ReferenceLine, ReferenceArea, LabelList } from 'recharts' import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser" const DEMO_TREND_DATA = [ - { name: 'Week 1', rank: 4500, label: 'NIT Trichy CSE' }, - { name: 'Week 2', rank: 4100, label: 'NIT Surathkal CSE' }, - { name: 'Week 3', rank: 3800, label: 'IIT Mandi EEE' }, - { name: 'Week 4', rank: 3300, label: 'IIT Ropar CSE' }, - { name: 'Week 5', rank: 2900, label: 'IIT Guwahati ECE' }, - { name: 'Week 6', rank: 2750, label: 'IIT Roorkee' }, -] + { name: '1', value: 0.120, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '2', value: 0.100, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '3', value: 0.075, ucl: 0.195, lcl: 0.005, cl: 0.10, target: 0.16 }, + { name: '4', value: 0.090, ucl: 0.195, lcl: 0.005, cl: 0.10, target: 0.16 }, + { name: '5', value: 0.119, ucl: 0.180, lcl: 0.020, cl: 0.10, target: 0.16 }, + { name: '6', value: 0.110, ucl: 0.180, lcl: 0.020, cl: 0.10, target: 0.16 }, + { name: '7', value: 0.110, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '8', value: 0.160, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '9', value: 0.111, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, + { name: '10', value: 0.067, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, + { name: '11', value: 0.180, ucl: 0.178, lcl: 0.022, cl: 0.10, target: 0.16 }, + { name: '12', value: 0.125, ucl: 0.178, lcl: 0.022, cl: 0.10, target: 0.16 }, + { name: '13', value: 0.075, ucl: 0.178, lcl: 0.022, cl: 0.10, target: 0.16 }, + { name: '14', value: 0.066, ucl: 0.180, lcl: 0.020, cl: 0.10, target: 0.16 }, + { name: '15', value: 0.055, ucl: 0.180, lcl: 0.020, cl: 0.10, target: 0.16 }, + { name: '16', value: 0.100, ucl: 0.195, lcl: 0.005, cl: 0.10, target: 0.16 }, + { name: '17', value: 0.125, ucl: 0.195, lcl: 0.005, cl: 0.10, target: 0.16 }, + { name: '18', value: 0.088, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, + { name: '19', value: 0.056, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, + { name: '20', value: 0.080, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '21', value: 0.050, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '22', value: 0.080, ucl: 0.185, lcl: 0.015, cl: 0.10, target: 0.16 }, + { name: '23', value: 0.100, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, + { name: '24', value: 0.067, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, + { name: '25', value: 0.100, ucl: 0.190, lcl: 0.010, cl: 0.10, target: 0.16 }, +]; -const ZERO_TREND_DATA = [ - { name: 'Week 1', rank: 0 }, - { name: 'Week 2', rank: 0 }, - { name: 'Week 3', rank: 0 }, - { name: 'Week 4', rank: 0 }, - { name: 'Week 5', rank: 0 }, - { name: 'Week 6', rank: 0 }, -] +const ZERO_TREND_DATA = DEMO_TREND_DATA.map(d => ({ ...d, value: 0 })); -// Custom Label to permanently show text on the graph (not on hover) -const CustomLabel = (props: any) => { - const { x, y, index, data } = props; - const point = data[index]; - if (!point || !point.label) return null; +// Custom dot to match the requested look +const CustomDot = (props: any) => { + const { cx, cy, payload } = props; - let anchor = "middle"; - let xPos = x; - let yPos = y - 20; - - if (index === 0) { - anchor = "start"; - xPos = x + 5; - } else if (index === data.length - 1) { - anchor = "end"; - xPos = x - 5; - } + // Find if this is the outlier (highest point, around 0.180) to color it red + const isOutlier = payload.value >= 0.180; return ( - - - {point.label} - - - Rank: {point.rank} - - + ); }; @@ -92,19 +92,46 @@ export default function CollegePredictorPage() { - - {/* User said static line, not dotted. So removed strokeDasharray from grid? Let's make it solid if they mean grid, or just the line. Line is monotone. */} - - - + + + + val.toFixed(3)} + axisLine={false} + tickLine={false} + label={{ value: 'Prediction Volatility', angle: -90, position: 'insideLeft', fill: 'var(--muted-foreground)', fontSize: 12, fontWeight: 'bold' }} + /> + + + {/* Target Spec Line Band */} + + + {/* Target Line */} + + + {/* Center Line (CL) */} + + + {/* Control Limits (stepped) */} + + + + {/* Main Data Line */} } + dataKey="value" + stroke="#3b82f6" + strokeWidth={1.5} + dot={} + activeDot={{ r: 6, fill: 'var(--cyan-ai)' }} + isAnimationActive={true} />