57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import React from 'react';
|
|
import {
|
|
AreaChart,
|
|
Area,
|
|
XAxis,
|
|
YAxis,
|
|
CartesianGrid,
|
|
Tooltip,
|
|
ResponsiveContainer,
|
|
} from 'recharts';
|
|
import { BandwidthHistoryPoint } from '../../types';
|
|
|
|
interface BandwidthChartProps {
|
|
data: BandwidthHistoryPoint[];
|
|
}
|
|
|
|
const BandwidthChart: React.FC<BandwidthChartProps> = ({ data }) => {
|
|
return (
|
|
<div className="bg-white p-6 rounded-xl shadow-sm h-full">
|
|
<h2 className="text-xl font-bold mb-4">Penggunaan Bandwidth (24 Jam)</h2>
|
|
<div className="h-80">
|
|
<ResponsiveContainer width="100%" height="100%">
|
|
<AreaChart data={data} margin={{ top: 5, right: 20, left: -15, bottom: 5 }}>
|
|
<defs>
|
|
<linearGradient id="colorUsage" x1="0" y1="0" x2="0" y2="1">
|
|
<stop offset="5%" stopColor="#ef4444" stopOpacity={0.8} />
|
|
<stop offset="95%" stopColor="#ef4444" stopOpacity={0} />
|
|
</linearGradient>
|
|
</defs>
|
|
<CartesianGrid strokeDasharray="3 3" stroke="#e0e0e0" />
|
|
<XAxis dataKey="time" fontSize={12} tick={{ fill: '#6b7280' }} interval={5} />
|
|
<YAxis fontSize={12} tick={{ fill: '#6b7280' }} unit=" Mbps" />
|
|
<Tooltip
|
|
contentStyle={{
|
|
backgroundColor: 'rgba(255, 255, 255, 0.9)',
|
|
border: '1px solid #ccc',
|
|
borderRadius: '8px',
|
|
}}
|
|
formatter={(value: number) => [`${value.toFixed(1)} Mbps`, 'Penggunaan']}
|
|
/>
|
|
<Area
|
|
type="monotone"
|
|
dataKey="usage"
|
|
stroke="#ef4444"
|
|
fillOpacity={1}
|
|
fill="url(#colorUsage)"
|
|
strokeWidth={2}
|
|
/>
|
|
</AreaChart>
|
|
</ResponsiveContainer>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default BandwidthChart;
|