From b58d732764a692966761b0b87e3f11122598f685 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sun, 28 Dec 2025 01:15:23 +0100 Subject: [PATCH] Improved chart --- src/app/monitoring/page.tsx | 287 ++++++--------------------- src/components/GradientAreaChart.tsx | 83 ++++++++ 2 files changed, 143 insertions(+), 227 deletions(-) create mode 100644 src/components/GradientAreaChart.tsx diff --git a/src/app/monitoring/page.tsx b/src/app/monitoring/page.tsx index ff5903c..d58fcd9 100644 --- a/src/app/monitoring/page.tsx +++ b/src/app/monitoring/page.tsx @@ -1,52 +1,41 @@ "use client"; import { DashboardLayout } from "@/components/dashboard/DashboardLayout"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import { Badge } from "@/components/ui/badge"; -import { - LineChart, - Line, - XAxis, - YAxis, - Tooltip, - ResponsiveContainer, - AreaChart, - Area, -} from "recharts"; import { Progress } from "@/components/ui/progress"; -import RadialChart from "@/components/RadialChart"; -import { ArrowDownLeft, ArrowUpRight, Cpu, MemoryStick } from "lucide-react"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { type ChartConfig } from "@/components/ui/chart"; +import GradientAreaChart from "@/components/GradientAreaChart"; const cpuData = [ - { time: "00:00", value: 45 }, - { time: "01:00", value: 52 }, - { time: "02:00", value: 38 }, - { time: "03:00", value: 42 }, - { time: "04:00", value: 35 }, - { time: "05:00", value: 48 }, - { time: "06:00", value: 55 }, - { time: "07:00", value: 62 }, - { time: "08:00", value: 78 }, - { time: "09:00", value: 85 }, - { time: "10:00", value: 72 }, - { time: "11:00", value: 68 }, - { time: "12:00", value: 75 }, + { time: "00:00", cpu: 45 }, + { time: "01:00", cpu: 52 }, + { time: "02:00", cpu: 38 }, + { time: "03:00", cpu: 42 }, + { time: "04:00", cpu: 35 }, + { time: "05:00", cpu: 48 }, + { time: "06:00", cpu: 55 }, + { time: "07:00", cpu: 62 }, + { time: "08:00", cpu: 78 }, + { time: "09:00", cpu: 85 }, + { time: "10:00", cpu: 72 }, + { time: "11:00", cpu: 68 }, + { time: "12:00", cpu: 75 }, ]; const memoryData = [ - { time: "00:00", value: 62 }, - { time: "01:00", value: 64 }, - { time: "02:00", value: 58 }, - { time: "03:00", value: 61 }, - { time: "04:00", value: 59 }, - { time: "05:00", value: 63 }, - { time: "06:00", value: 67 }, - { time: "07:00", value: 72 }, - { time: "08:00", value: 78 }, - { time: "09:00", value: 82 }, - { time: "10:00", value: 76 }, - { time: "11:00", value: 74 }, - { time: "12:00", value: 71 }, + { time: "00:00", memory: 62 }, + { time: "01:00", memory: 64 }, + { time: "02:00", memory: 58 }, + { time: "03:00", memory: 61 }, + { time: "04:00", memory: 59 }, + { time: "05:00", memory: 63 }, + { time: "06:00", memory: 67 }, + { time: "07:00", memory: 72 }, + { time: "08:00", memory: 78 }, + { time: "09:00", memory: 82 }, + { time: "10:00", memory: 76 }, + { time: "11:00", memory: 74 }, + { time: "12:00", memory: 71 }, ]; const networkData = [ @@ -76,6 +65,19 @@ const containerMetrics = [ { name: "worker-queue-1", cpu: 55, memory: 48, network: "5.6 MB/s" }, ]; +const cpuChartConfig = { + cpu: { label: "CPU Usage", color: "var(--chart-1)" }, +} satisfies ChartConfig; + +const memoryChartConfig = { + memory: { label: "RAM Usage", color: "var(--chart-3)" }, +} satisfies ChartConfig; + +const networkChartConfig = { + in: { label: "Inbound", color: "var(--chart-2)" }, + out: { label: "Outbound", color: "var(--chart-4)" }, +} satisfies ChartConfig; + export default function MonitoringPage() { return ( - {/* Charts */} + {/* CPU & Memory Charts */}
- - - - CPU Usage Last 12 hours - - - -
- - - - - - - - - - - - - - -
-
-
- - - - - Memory Usage Last 12 hours - - - -
- - - - - - - - - - - - - - -
-
-
+ +
- {/* Network Chart */} - - - - Network I/O Last 12 hours - - - -
- - - - - - - - - -
-
-
-
- Inbound -
-
-
- Outbound -
-
- - +
+ +
{/* Container Metrics */} diff --git a/src/components/GradientAreaChart.tsx b/src/components/GradientAreaChart.tsx new file mode 100644 index 0000000..27c6ba6 --- /dev/null +++ b/src/components/GradientAreaChart.tsx @@ -0,0 +1,83 @@ +"use client"; + +import { + Card, + CardContent, + CardHeader, + CardTitle, + CardDescription, +} from "@/components/ui/card"; +import { AreaChart, Area, XAxis, CartesianGrid } from "recharts"; +import { + ChartContainer, + ChartTooltip, + ChartTooltipContent, + type ChartConfig, +} from "@/components/ui/chart"; + +export default function GradientAreaChart({ + title, + data, + config, +}: { + title: string; + data: any[]; + config: ChartConfig; +}) { + return ( + + + {title} + Last 12 hours + + + + + + + } /> + + {Object.entries(config).map(([key, config]) => ( + + + + + ))} + + {Object.entries(config).map(([key, config]) => ( + + ))} + + + + + ); +}