diff --git a/client/src/components/dashboard/CpuChart.tsx b/client/src/components/dashboard/CpuChart.tsx index f2a261e..c88457e 100644 --- a/client/src/components/dashboard/CpuChart.tsx +++ b/client/src/components/dashboard/CpuChart.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useState } from "react" +import { useEffect, useRef } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { cn } from "@/lib/utils" @@ -32,17 +32,13 @@ function loadColor(load: number) { } export function CpuChart({ history, loadAvg }: CpuChartProps) { - const [tick, setTick] = useState(0) const prevLenRef = useRef(0) const currentCpu = history.length > 0 ? history[history.length - 1].cpuPercent : 0 const color = cpuColor(currentCpu) - // Trigger CSS transition whenever a new point arrives + // Track history length changes (used to drive CSS transitions via key changes) useEffect(() => { - if (history.length !== prevLenRef.current) { - prevLenRef.current = history.length - setTick(t => t + 1) - } + prevLenRef.current = history.length }, [history.length]) // Assign fixed x positions: latest point always at right edge, older ones to the left