// 双线图表(网卡带宽 rx+tx)// Logan.Li import { Network } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Brush, } from 'recharts'; import type { AggType, BucketPoint } from './types'; interface DualLineChartProps { title: string; currentRx: string; currentTx: string; rxData: BucketPoint[]; txData: BucketPoint[]; aggType: AggType; unit: string; } export function DualLineChart({ title, currentRx, currentTx, rxData, txData, aggType, unit, }: DualLineChartProps) { const chartData = rxData.map((d, i) => ({ time: d.time, timestamp: d.timestamp, rx: d[aggType] ?? 0, tx: txData[i]?.[aggType] ?? 0, })); const rxGradId = `grad-rx-${title.replace(/\s/g, '')}`; const txGradId = `grad-tx-${title.replace(/\s/g, '')}`; return (
{title}
接收 {currentRx} 发送 {currentTx}
{chartData.length === 0 ? (
暂无数据
) : ( [`${v.toFixed(2)} ${unit}`, name === 'rx' ? '接收' : '发送']} labelFormatter={(label) => `时间: ${label}`} /> )}
); }