diff --git a/app/sites/[id]/pagespeed/page.tsx b/app/sites/[id]/pagespeed/page.tsx index 5463f20..3a22b43 100644 --- a/app/sites/[id]/pagespeed/page.tsx +++ b/app/sites/[id]/pagespeed/page.tsx @@ -8,20 +8,7 @@ import { updatePageSpeedConfig, triggerPageSpeedCheck, getPageSpeedLatest, type import { toast, Button } from '@ciphera-net/ui' import { motion } from 'framer-motion' import ScoreGauge from '@/components/pagespeed/ScoreGauge' -import { - AreaChart, - Area, - XAxis, - YAxis, - CartesianGrid, - ReferenceLine, -} from 'recharts' -import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from '@/components/charts' - -// * Chart configuration for score trend -const chartConfig = { - score: { label: 'Performance', color: 'var(--chart-1)' }, -} satisfies ChartConfig +import { AreaChart as VisxAreaChart, Area as VisxArea, Grid as VisxGrid, XAxis as VisxXAxis, YAxis as VisxYAxis, ChartTooltip as VisxChartTooltip } from '@/components/ui/area-chart' // * Metric status thresholds (Google's Core Web Vitals thresholds) function getMetricStatus(metric: string, value: number | null): { label: string; color: string } { @@ -225,14 +212,11 @@ export default function PageSpeedPage() { ) } - // * Prepare chart data from history + // * Prepare chart data from history (visx needs Date objects for x-axis) const chartData = (historyChecks ?? []).map(c => ({ - date: new Date(c.checked_at).toLocaleDateString('en-GB', { day: '2-digit', month: 'short' }), - score: c.performance_score, + dateObj: new Date(c.checked_at), + score: c.performance_score ?? 0, })) - // * Check if all chart labels are the same (single day of data) - const uniqueDates = new Set(chartData.map(d => d.date)) - const hideXAxis = uniqueDates.size <= 1 // * Parse audits into groups by Lighthouse category const audits = currentCheck?.audits ?? [] @@ -446,62 +430,45 @@ export default function PageSpeedPage() { - {/* Section 3 — Score Trend Chart */} + {/* Section 3 — Score Trend Chart (visx) */} {chartData.length >= 2 && (