feat(system-resources-widget): add label display mode option (#4086)

This commit is contained in:
Meier Lukas
2025-09-19 16:19:58 +02:00
committed by GitHub
parent 2a67d2f9da
commit 312e084e2c
8 changed files with 108 additions and 14 deletions

View File

@@ -1,16 +1,20 @@
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");
@@ -27,6 +31,8 @@ export const SystemResourceMemoryChart = ({
dataKey={"index"}
series={[{ name: "usage", color: "red.6" }]}
title={t("memory")}
icon={IconBrain}
labelDisplayMode={labelDisplayMode}
yAxisProps={{ domain: [0, totalCapacityInBytes] }}
lastValue={percentageUsed !== undefined ? `${Math.round(percentageUsed * 100)}%` : undefined}
tooltipProps={{