import { Fragment } from "react"
/** Compact RX/TX history shared by traffic cards. Gaps remain gaps. */
export function TrafficMiniChart({ rx, tx, height = 44 }: { rx: number[]; tx: number[]; height?: number }) {
const valid = (value: number) => Number.isFinite(value) && value >= 0
const values = [...rx, ...tx].filter(valid)
if (!values.length) return
Нет истории трафика
const width = 300
const count = Math.max(rx.length, tx.length)
const max = Math.max(...values, 1) * 1.1
const segments = (series: number[]) => {
const result: Array> = []
let current: Array<{ x: number; y: number }> = []
series.forEach((value, index) => {
if (!valid(value)) { current = []; return }
if (!current.length) result.push(current)
current.push({ x: count <= 1 ? width / 2 : index / (count - 1) * width, y: height - value / max * height })
})
return result
}
return (
)
}