import { Paper, Text } from "@mantine/core"; import { IconBrain } from "@tabler/icons-react"; import { humanFileSize } from "@homarr/common"; import { useScopedI18n } from "@homarr/translation/client"; import type { LabelDisplayModeOption } from ".."; import { CommonChart } from "./common-chart"; export const SystemResourceMemoryChart = ({ memoryUsageOverTime, totalCapacityInBytes, labelDisplayMode, }: { memoryUsageOverTime: number[]; totalCapacityInBytes: number; labelDisplayMode: LabelDisplayModeOption; }) => { const chartData = memoryUsageOverTime.map((usage, index) => ({ index, usage })); const t = useScopedI18n("widget.systemResources.card"); const percentageUsed = memoryUsageOverTime.length > 0 ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion memoryUsageOverTime[memoryUsageOverTime.length - 1]! / totalCapacityInBytes : undefined; return ( { if (!payload) { return null; } const value = payload[0] ? Number(payload[0].value) : 0; return ( {humanFileSize(value)} / {humanFileSize(totalCapacityInBytes)} ( {Math.round((value / totalCapacityInBytes) * 100)}%) ); }, }} /> ); };