import { format } from "date-fns"; import { Area, AreaChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, YAxis, } from "recharts"; import type { DockerStatsJSON } from "./show"; import { convertMemoryToBytes } from "./show"; 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}`, // @ts-ignore usage: (convertMemoryToBytes(item.value.used) / 1024 ** 3).toFixed(2), }; }); return (
{`Date: ${format(new Date(payload[0].payload.time), "PPpp")}`}
)}{`Memory usage: ${payload[0].payload.usage} GB`}