"use client"; import { AreaChart } from "@mantine/charts"; import { Group, Paper, Stack, Text } from "@mantine/core"; import type { ThroughputPoint } from "./throughput-history"; /** * Series colours. * * Not copied from the `systemResources` network chart, which pairs `orange.5` * with `yellow.5`: that pair scores a normal-vision ΔE of 12.1, below the * legibility floor of 15, so even readers with full colour vision struggle to * tell the two lines apart. This pair was validated instead, and passes every * check — lightness band, chroma, colour-vision-deficiency separation, * normal-vision separation and surface contrast — against BOTH the light and * the dark chart surface, so one pair serves both themes. */ const DOWN_COLOR = "blue.7"; const UP_COLOR = "orange.8"; const CHART_HEIGHT = 44; /** * A dot carries the series identity so the figure beside it can stay in muted * ink: colour is never the only thing distinguishing up from down — the arrow * glyph and the label do it too. */ const SeriesKey = ({ color, label }: { color: string; label: string }) => ( ● {label} ); /** * Defined at module level rather than inline in the `content` prop: recharts * clones this element and injects `payload`, so it keeps a stable identity * across renders. The repo's other chart tooltips pass a closure instead and * each carries a `no-unstable-nested-components` warning for it. */ const ThroughputTooltip = ({ payload, formatRate, upName, downName, }: { payload?: { name?: string | number; value?: string | number }[]; formatRate: (bitsPerSecond: number) => string; upName: string; downName: string; }) => { if (!payload || payload.length === 0) return null; return ( {payload.map((item) => ( {item.name === "up" ? `↑ ${upName}` : `↓ ${downName}`} {formatRate(Number(item.value))} ))} ); }; export interface ThroughputChartProps { history: ThroughputPoint[]; /** Rendered beside the up marker, already formatted. */ upLabel: string; /** Rendered beside the down marker, already formatted. */ downLabel: string; /** Formats a raw bits-per-second value for the tooltip. */ formatRate: (bitsPerSecond: number) => string; upName: string; downName: string; } export const ThroughputChart = ({ history, upLabel, downLabel, formatRate, upName, downName, }: ThroughputChartProps) => ( , }} /> );