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,10 +1,18 @@
import { Paper, Text } from "@mantine/core";
import { IconCpu } from "@tabler/icons-react";
import { useScopedI18n } from "@homarr/translation/client";
import { LabelDisplayModeOption } from "..";
import { CommonChart } from "./common-chart";
export const SystemResourceCPUChart = ({ cpuUsageOverTime }: { cpuUsageOverTime: number[] }) => {
export const SystemResourceCPUChart = ({
cpuUsageOverTime,
labelDisplayMode,
}: {
cpuUsageOverTime: number[];
labelDisplayMode: LabelDisplayModeOption;
}) => {
const chartData = cpuUsageOverTime.map((usage, index) => ({ index, usage }));
const t = useScopedI18n("widget.systemResources.card");
@@ -14,11 +22,13 @@ export const SystemResourceCPUChart = ({ cpuUsageOverTime }: { cpuUsageOverTime:
dataKey={"index"}
series={[{ name: "usage", color: "blue.5" }]}
title={t("cpu")}
icon={IconCpu}
lastValue={
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
cpuUsageOverTime.length > 0 ? `${Math.round(cpuUsageOverTime[cpuUsageOverTime.length - 1]!)}%` : undefined
}
yAxisProps={{ domain: [0, 100] }}
labelDisplayMode={labelDisplayMode}
tooltipProps={{
content: ({ payload }) => {
if (!payload) {