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

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

{`Memory usage: ${payload[0].payload.usage} GB`}

); } return null; };