diff --git a/AppImage/components/metrics-dialog.tsx b/AppImage/components/metrics-dialog.tsx index 5975186..72b1ba7 100644 --- a/AppImage/components/metrics-dialog.tsx +++ b/AppImage/components/metrics-dialog.tsx @@ -4,7 +4,7 @@ import { useState, useEffect } from "react" import { Button } from "@/components/ui/button" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { ArrowLeft, Loader2 } from "lucide-react" -import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from "recharts" +import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from "recharts" interface MetricsViewProps { vmid: number @@ -131,170 +131,239 @@ export function MetricsView({ vmid, vmName, vmType, metricType, onBack }: Metric } } + const formatXAxisTick = (tick: any) => { + return tick + } + const renderChart = () => { if (loading) { return ( -
- +
+
) } if (error) { return ( -
-

{error}

+
+

{error}

) } if (data.length === 0) { return ( -
+

No data available

) } - const tickInterval = Math.ceil(data.length / 10) + // Calculate tick interval based on data length + const tickInterval = Math.ceil(data.length / 8) switch (metricType) { case "cpu": return ( - - + + Math.ceil(dataMax * 1.15)]} + domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.2)]} + allowDataOverflow={false} /> - - + + ) case "memory": return ( - - + + Math.ceil(dataMax * 1.15)]} + domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.2)]} + allowDataOverflow={false} /> - - + + ) case "network": return ( - - + + Math.ceil(dataMax * 1.15)]} + domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.2)]} + allowDataOverflow={false} /> - - - + + + ) case "disk": return ( - - + + Math.ceil(dataMax * 1.15)]} + domain={[0, (dataMax: number) => Math.ceil(dataMax * 1.2)]} + allowDataOverflow={false} /> - - + - + ) + + default: + return null } }