/* eslint-disable @typescript-eslint/no-explicit-any */ import type { LineChartSeries } from "@mantine/charts"; import { LineChart } from "@mantine/charts"; import { Card, Center, Group, Loader, Stack, Text, useMantineColorScheme, useMantineTheme } from "@mantine/core"; import { useElementSize, useHover, useMergedRef } from "@mantine/hooks"; import type { TooltipProps, YAxisProps } from "recharts"; import { useRequiredBoard } from "@homarr/boards/context"; export const CommonChart = ({ data, dataKey, series, title, tooltipProps, yAxisProps, lastValue, }: { data: Record[]; dataKey: string; series: LineChartSeries[]; title: string; tooltipProps?: TooltipProps; yAxisProps?: Omit; lastValue?: string; }) => { const { ref: elementSizeRef, height } = useElementSize(); const theme = useMantineTheme(); const scheme = useMantineColorScheme(); const board = useRequiredBoard(); const { hovered, ref: hoverRef } = useHover(); const ref = useMergedRef(elementSizeRef, hoverRef); const opacity = board.opacity / 100; const backgroundColor = scheme.colorScheme === "dark" ? `rgba(57, 57, 57, ${opacity})` : `rgba(246, 247, 248, ${opacity})`; return ( {data.length > 1 && height > 40 && !hovered && ( 100 ? "md" : "xs"} fw={"bold"}> {title} {lastValue && ( 100 ? "md" : "xs"} lineClamp={1}> {lastValue} )} )} {data.length <= 1 ? (
100 ? "md" : "xs"} color={"rgba(94, 94, 94, 1)"} />
) : ( = 64} yAxisProps={yAxisProps} /> )}
); };