import { format } from "date-fns"; import { Area, AreaChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, YAxis, } from "recharts"; import type { DockerStatsJSON } from "./show"; 1; interface Props { acummulativeData: DockerStatsJSON["network"]; } export const DockerNetworkChart = ({ acummulativeData }: Props) => { const transformedData = acummulativeData.map((item, index) => { return { time: item.time, name: `Point ${index + 1}`, inMB: item.value.inputMb.toFixed(2), outMB: item.value.outputMb.toFixed(2), }; }); return (
{/* @ts-ignore */} } />
); }; interface CustomTooltipProps { active: boolean; payload?: { color?: string; dataKey?: string; value?: number; payload: { time: string; inMB: number; outMB: number; }; }[]; } const CustomTooltip = ({ active, payload }: CustomTooltipProps) => { if (active && payload && payload.length && payload[0]) { return (

{`Date: ${format(new Date(payload[0].payload.time), "PPpp")}`}

{`In MB Usage: ${payload[0].payload.inMB} MB`}

{`Out MB Usage: ${payload[0].payload.outMB} MB`}

); } return null; };