-
{formatNumber(p99)}{" "}
-
ms
+
+ {formatNumber(p99)}
+ ms
);
},
diff --git a/apps/web/src/components/monitor-charts/chart.tsx b/apps/web/src/components/monitor-charts/chart.tsx
index 7c596f0e..6b17a17e 100644
--- a/apps/web/src/components/monitor-charts/chart.tsx
+++ b/apps/web/src/components/monitor-charts/chart.tsx
@@ -1,12 +1,15 @@
"use client";
-import type { CustomTooltipProps, EventProps } from "@tremor/react";
-import { LineChart } from "@tremor/react";
-import { useState } from "react";
-
-import { cn } from "@/lib/utils";
import type { Region } from "@openstatus/db/src/schema/constants";
-import { dataFormatter, regionFormatter } from "./utils";
+import {
+ ChartContainer,
+ ChartLegend,
+ ChartLegendContent,
+ ChartTooltip,
+ ChartTooltipContent,
+} from "@openstatus/ui";
+import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
+import { regionFormatter } from "./utils";
interface ChartProps {
data: { timestamp: string; [key: string]: string | number }[];
@@ -14,85 +17,132 @@ interface ChartProps {
}
export function Chart({ data, regions }: ChartProps) {
- const [value, setValue] = useState
(null);
return (
- customTooltip({ ...props, value })}
- showAnimation={true}
- />
+
+
+ }
+ verticalAlign="top"
+ />
+ {
+ const min = Math.max(Math.abs(dataMin) - 25, 0);
+ const max = dataMax + 100;
+ return [min, max];
+ }}
+ />
+ {
+ return new Date(value).toLocaleDateString("en-US", {
+ day: "numeric",
+ month: "short",
+ hour: "numeric",
+ minute: "numeric",
+ });
+ }}
+ />
+
+ {
+ return new Date(value).toLocaleDateString("en-US", {
+ day: "numeric",
+ month: "short",
+ hour: "numeric",
+ minute: "numeric",
+ });
+ }}
+ formatter={(value, name) => (
+ <>
+
+ {/* {chartConfig[name as keyof typeof chartConfig]?.label || name} */}
+ {regionFormatter(name as Region)}
+
+ {value}
+
+ ms
+
+
+ >
+ )}
+ />
+ }
+ />
+ {regions.map((region) => {
+ return (
+
+ );
+ })}
+
+
);
}
-const customTooltip = ({
- payload,
- active,
- label,
- value,
-}: CustomTooltipProps & { value: EventProps }) => {
- if (!active || !payload) return null;
- return (
-
-
-
- {label}
-
- {payload
- .filter((category) => category.type !== undefined) // tremor adds additional data to the payload, we don't want that
- .map((category, idx) => {
- const isActive = value
- ? value.categoryClicked === category.dataKey
- : true;
- return (
-
- key={idx}
- className={cn("flex flex-1 gap-2", !isActive && "opacity-60")}
- >
-
-
-
- {regionFormatter(category.dataKey as Region)}
-
-
- {dataFormatter(category.value as number)}
-
-
-
- );
- })}
-
-
- );
+// basic tailwindcss 500 colors in hsl format
+const chartConfig: Record = {
+ ams: { label: "AMS", color: "hsl(217.2 91.2% 59.8%)" },
+ arn: { label: "ARN", color: "hsl(238.7 83.5% 66.7%)" },
+ atl: { label: "ATL", color: "hsl(258.3 89.5% 66.3%)" },
+ bog: { label: "BOG", color: "hsl(270.7 91% 65.1%)" },
+ bom: { label: "BOM", color: "hsl(292.2 84.1% 60.6%)" },
+ bos: { label: "BOS", color: "hsl(330.4 81.2% 60.4%)" },
+ cdg: { label: "CDG", color: "hsl(349.7 89.2% 60.2%)" },
+ den: { label: "DEN", color: "hsl(215.4 16.3% 46.9%)" },
+ dfw: { label: "DFW", color: "hsl(220 8.9% 46.1%)" },
+ ewr: { label: "EWR", color: "hsl(240 3.8% 46.1%)" },
+ eze: { label: "EZE", color: "hsl(0 0% 45.1%)" },
+ fra: { label: "FRA", color: "hsl(25 5.3% 44.7%)" },
+ gdl: { label: "GDL", color: "hsl(0 84.2% 60.2%)" },
+ gig: { label: "GIG", color: "hsl(24.6 95% 53.1%)" },
+ gru: { label: "GRU", color: "hsl(37.7 92.1% 50.2%)" },
+ hkg: { label: "HKG", color: "hsl(45.4 93.4% 47.5%)" },
+ iad: { label: "IAD", color: "hsl(83.7 80.5% 44.3%)" },
+ jnb: { label: "JNB", color: "hsl(142.1 70.6% 45.3%)" },
+ lax: { label: "LAX", color: "hsl(160.1 84.1% 39.4%)" },
+ lhr: { label: "LHR", color: "hsl(173.4 80.4% 40%)" },
+ mad: { label: "MAD", color: "hsl(188.7 94.5% 42.7%)" },
+ mia: { label: "MIA", color: "hsl(198.6 88.7% 48.4%)" },
+ nrt: { label: "NRT", color: "hsl(217.2 91.2% 59.8%)" },
+ ord: { label: "ORD", color: "hsl(238.7 83.5% 66.7%)" },
+ otp: { label: "OTP", color: "hsl(258.3 89.5% 66.3%)" },
+ phx: { label: "PHX", color: "hsl(270.7 91% 65.1%)" },
+ qro: { label: "QRO", color: "hsl(292.2 84.1% 60.6%)" },
+ scl: { label: "SCL", color: "hsl(330.4 81.2% 60.4%)" },
+ sjc: { label: "SJC", color: "hsl(349.7 89.2% 60.2%)" },
+ sea: { label: "SEA", color: "hsl(215.4 16.3% 46.9%)" },
+ sin: { label: "SIN", color: "hsl(220 8.9% 46.1%)" },
+ syd: { label: "SYD", color: "hsl(240 3.8% 46.1%)" },
+ waw: { label: "WAW", color: "hsl(0 0% 45.1%)" },
+ yul: { label: "YUL", color: "hsl(25 5.3% 44.7%)" },
+ yyz: { label: "YYZ", color: "hsl(0 84.2% 60.2%)" },
};
diff --git a/apps/web/src/components/monitor-charts/region-table.tsx b/apps/web/src/components/monitor-charts/region-table.tsx
index 999a1aff..9aa89111 100644
--- a/apps/web/src/components/monitor-charts/region-table.tsx
+++ b/apps/web/src/components/monitor-charts/region-table.tsx
@@ -18,7 +18,7 @@ export interface RegionTableProps {
regions: Region[];
data: {
regions: Region[];
- data: (Partial> & { timestamp: string })[];
+ data: (Partial> & { timestamp: string })[];
};
metricsByRegion: ResponseTimeMetricsByRegion[];
caption?: string;
@@ -60,7 +60,12 @@ export function RegionTable({
-
+ ({
+ timestamp: d.timestamp,
+ latency: d[region],
+ }))}
+ />
{formatNumber(metrics?.p50Latency)}
diff --git a/apps/web/src/components/monitor-charts/simple-chart-wrapper.tsx b/apps/web/src/components/monitor-charts/simple-chart-wrapper.tsx
index b62a883c..e58502e5 100644
--- a/apps/web/src/components/monitor-charts/simple-chart-wrapper.tsx
+++ b/apps/web/src/components/monitor-charts/simple-chart-wrapper.tsx
@@ -21,7 +21,12 @@ export function SimpleChartWrapper({
-
+ ({
+ timestamp: d.timestamp,
+ latency: d[region],
+ }))}
+ />
);
}
diff --git a/apps/web/src/components/monitor-charts/simple-chart.tsx b/apps/web/src/components/monitor-charts/simple-chart.tsx
index f4355dca..9d286c63 100644
--- a/apps/web/src/components/monitor-charts/simple-chart.tsx
+++ b/apps/web/src/components/monitor-charts/simple-chart.tsx
@@ -1,71 +1,80 @@
"use client";
-import type { CustomTooltipProps } from "@tremor/react";
-import { LineChart } from "@tremor/react";
+import { Line, LineChart, XAxis } from "recharts";
-import { cn } from "@/lib/utils";
-import { dataFormatter } from "./utils";
+import {
+ ChartContainer,
+ ChartTooltip,
+ ChartTooltipContent,
+} from "@openstatus/ui";
+
+const chartConfig = {
+ latency: {
+ label: "Latency",
+ color: "hsl(var(--status-operational))",
+ },
+};
export interface SimpleChartProps {
- data: { timestamp: string; [key: string]: string }[];
- region: string;
+ data: { timestamp: string; latency: number | undefined }[];
}
// TODO: allow click to open `./details` intercepting route
-export function SimpleChart({ data, region }: SimpleChartProps) {
+export function SimpleChart({ data }: SimpleChartProps) {
return (
-