"use client" interface BandwidthChartProps { rx: number[] tx: number[] } export function BandwidthChart({ rx, tx }: BandwidthChartProps) { const W = 600, H = 200 const pad = { l: 44, r: 12, t: 12, b: 28 } const iw = W - pad.l - pad.r const ih = H - pad.t - pad.b const maxVal = Math.max(...rx, ...tx) * 1.15 const xAt = (i: number, n: number) => pad.l + (i / (n - 1)) * iw const yAt = (v: number) => pad.t + (1 - v / maxVal) * ih const areaPath = (arr: number[]) => { const top = arr.map((v, i) => `${xAt(i, arr.length).toFixed(1)},${yAt(v).toFixed(1)}`).join(" L ") return `M ${pad.l},${pad.t + ih} L ${top} L ${pad.l + iw},${pad.t + ih} Z` } const linePath = (arr: number[]) => arr.map((v, i) => `${xAt(i, arr.length).toFixed(1)},${yAt(v).toFixed(1)}`).join(" ") return (
{[0, 0.25, 0.5, 0.75, 1].map((p, i) => ( {Math.round(maxVal * (1 - p))} ))} {[0, 15, 30, 45, 59].map((i) => ( -{60 - i}м ))} {/* Legend */}
{[ { key: "rx", label: "RX ↓", color: "var(--chart-rx)" }, { key: "tx", label: "TX ↑", color: "var(--chart-tx)" }, ].map(({ key, label, color }) => (
{label}
))}
) }