From c9de35fad2e781c2913981174d936405e4a8def2 Mon Sep 17 00:00:00 2001 From: Sven van Ginkel Date: Mon, 21 Sep 2026 20:49:11 +0200 Subject: [PATCH] feat: change network packet loss to a red line (#2377) --- .../components/routes/system/charts/monitors-charts.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/site/src/components/routes/system/charts/monitors-charts.tsx b/internal/site/src/components/routes/system/charts/monitors-charts.tsx index a900b53a..0602611c 100644 --- a/internal/site/src/components/routes/system/charts/monitors-charts.tsx +++ b/internal/site/src/components/routes/system/charts/monitors-charts.tsx @@ -27,6 +27,8 @@ type MonitorChartBaseProps = MonitorChartProps & { tickFormatter: (value: number) => string contentFormatter: ({ value }: { value: number | string }) => string | number domain?: [number | "auto", number | "auto"] + /** Overrides the per-monitor line colors (e.g. a fixed color for single-monitor charts). */ + color?: string } function MonitorChart({ @@ -41,6 +43,7 @@ function MonitorChart({ tickFormatter, contentFormatter, domain, + color, showFilter = monitors.length > 1, }: MonitorChartBaseProps) { const storedFilter = useStore($monitorFilter) @@ -67,11 +70,12 @@ function MonitorChart({ label, dataKey: (record: NetworkMonitorStatsRecord) => record.stats?.[p.id]?.[metric] ?? null, dot, - color: count <= 5 ? i + 1 : `hsl(${(i * 360) / count}, var(--chart-saturation), var(--chart-lightness))`, + color: + color ?? (count <= 5 ? i + 1 : `hsl(${(i * 360) / count}, var(--chart-saturation), var(--chart-lightness))`), }) } return { dataPoints: points, visibleKeys: visibleIDs } - }, [monitors, filter, metric, chartData.chartTime]) + }, [monitors, filter, metric, chartData.chartTime, color]) const filteredMonitorStats = useMemo(() => { if (!visibleKeys.length) return monitorStats @@ -200,6 +204,7 @@ export function LossChart({ monitorStats, grid, monitors, chartData, empty, titl title={title} description={t`Packet loss (%)`} domain={[0, 100]} + color="var(--destructive)" tickFormatter={(value) => `${toFixedFloat(value, value >= 10 ? 0 : 1)}%`} contentFormatter={({ value }) => { if (typeof value !== "number") {