diff --git a/ground-server/package-lock.json b/ground-server/package-lock.json index 9d81f0b..e33315b 100644 --- a/ground-server/package-lock.json +++ b/ground-server/package-lock.json @@ -24,7 +24,6 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.0.4", - "date-fns": "^4.1.0", "lucide-react": "^0.468.0", "next": "15.1.4", "next-auth": "^5.0.0-beta.25", @@ -3192,16 +3191,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/date-fns": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", - "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/kossnocorp" - } - }, "node_modules/debug": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", diff --git a/ground-server/package.json b/ground-server/package.json index 2745cd1..d321bf8 100644 --- a/ground-server/package.json +++ b/ground-server/package.json @@ -25,7 +25,6 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.0.4", - "date-fns": "^4.1.0", "lucide-react": "^0.468.0", "next": "15.1.4", "next-auth": "^5.0.0-beta.25", diff --git a/ground-server/src/components/conops/live-value-with-historical-graph.tsx b/ground-server/src/components/conops/live-value-with-historical-graph.tsx index 64ef7d8..440694c 100644 --- a/ground-server/src/components/conops/live-value-with-historical-graph.tsx +++ b/ground-server/src/components/conops/live-value-with-historical-graph.tsx @@ -1,7 +1,6 @@ "use client"; import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"; -import { format } from "date-fns"; // Import date-fns import { useData } from "@/contexts/data-context"; import { ChartConfig, @@ -10,7 +9,7 @@ import { ChartTooltipContent, } from "@/components/ui/chart"; -function GetConfig(label: string) { +function getConfig(label: string) { const chartConfig = { config: { label: label, @@ -20,6 +19,14 @@ function GetConfig(label: string) { return chartConfig; } +function tickFormatter(tick: any) { + const date = new Date(tick); + const hours = date.getHours().toString().padStart(2, '0'); + const minutes = date.getMinutes().toString().padStart(2, '0'); + const formattedTime = `${hours}:${minutes}`; + return formattedTime; +} + interface LiveValueWithHistoricalGraphProps { label: string; dbField: string; @@ -44,7 +51,7 @@ export function LiveValueWithHistoricalGraph({

{duration}-Minute {label} History

- + ({ @@ -57,7 +64,7 @@ export function LiveValueWithHistoricalGraph({ format(new Date(tick), "HH:mm")} + tickFormatter={tickFormatter} tickLine={false} axisLine={false} tickMargin={8} diff --git a/ground-server/src/components/widgets/graph-widget.tsx b/ground-server/src/components/widgets/graph-widget.tsx index 578d1ad..f5285f2 100644 --- a/ground-server/src/components/widgets/graph-widget.tsx +++ b/ground-server/src/components/widgets/graph-widget.tsx @@ -1,5 +1,4 @@ import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"; -import { format } from "date-fns"; // Import date-fns import { ChartConfig, @@ -15,7 +14,7 @@ import { } from "@/lib/definitions"; import { useData } from "@/contexts/data-context"; -function GetConfig(channel: TelemetryChannel) { +function getConfig(channel: TelemetryChannel) { const chartConfig = { config: { label: channel.label, @@ -25,6 +24,14 @@ function GetConfig(channel: TelemetryChannel) { return chartConfig; } +function tickFormatter(tick: any) { + const date = new Date(tick); + const hours = date.getHours().toString().padStart(2, '0'); + const minutes = date.getMinutes().toString().padStart(2, '0'); + const formattedTime = `${hours}:${minutes}`; + return formattedTime; +} + function GenericHistoricalChart( duration: number, data: DataPoint[], @@ -37,7 +44,7 @@ function GenericHistoricalChart(

{duration}-Minute {channel.label} History

- + ({ @@ -50,7 +57,7 @@ function GenericHistoricalChart( format(new Date(tick), "HH:mm")} + tickFormatter={tickFormatter} tickLine={false} axisLine={false} tickMargin={8}