fix(ui): отличать пустую историю трафика от нулевой
This commit is contained in:
1 parent
7c6f937cec
commit
ec8e28d15d
4 files changed
+35
-12
No files matched your search
@@ -60,8 +60,8 @@ function toChartData(rx: number[], tx: number[], rangeMinutes: number) {
|
||||
const minutesAgo = Math.round((1 - i / denom) * rangeMinutes)
|
||||
return {
|
||||
time: formatRangeAgo(minutesAgo),
|
||||
rx: rx[i] ?? 0,
|
||||
tx: tx[i] ?? 0,
|
||||
rx: Number.isFinite(rx[i]) && rx[i] >= 0 ? rx[i] : null,
|
||||
tx: Number.isFinite(tx[i]) && tx[i] >= 0 ? tx[i] : null,
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -82,8 +82,11 @@ export function TrafficRxTxChart({
|
||||
const data = toChartData(rx, tx, rangeMinutes)
|
||||
const tickEvery = Math.max(1, Math.ceil(data.length / 6))
|
||||
|
||||
const chart = (
|
||||
<div className="flex flex-col gap-4">
|
||||
const hasData = data.some(point => point.rx !== null || point.tx !== null)
|
||||
const chart = !hasData ? (
|
||||
<p role="status" className="flex min-h-[220px] items-center justify-center text-sm text-muted-foreground">Нет исторических измерений за выбранный период</p>
|
||||
) : (
|
||||
<div role="region" aria-label="История RX/TX" className="flex flex-col gap-4">
|
||||
<ChartContainer config={chartConfig} className="-ms-4 aspect-auto h-[220px] w-full">
|
||||
<LineChart data={data} margin={{ top: 5, right: 5, left: 5, bottom: 5 }}>
|
||||
<CartesianGrid
|
||||
|
||||
Reference in new issue
Block a user