import { format } from "date-fns"; import { Area, AreaChart, CartesianGrid, YAxis } from "recharts"; import { type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, } from "@/components/ui/chart"; import type { DockerStatsJSON } from "./show-free-container-monitoring"; interface Props { accumulativeData: DockerStatsJSON["block"]; } const chartConfig = { readMb: { label: "Read (MB)", color: "hsl(var(--chart-1))", }, writeMb: { label: "Write (MB)", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig; export const DockerBlockChart = ({ accumulativeData }: Props) => { const transformedData = accumulativeData.map((item, index) => ({ time: item.time, name: `Point ${index + 1}`, readMb: item.value.readMb, writeMb: item.value.writeMb, })); return ( { const time = payload?.[0]?.payload?.time; return time ? format(new Date(time), "PPpp") : ""; }} formatter={(value, name) => { const label = name === "readMb" ? "Read" : "Write"; return [`${value} MB`, label]; }} /> } /> } /> ); };