y axis formatting

This commit is contained in:
Alex Holliday committed 2026-01-29 00:04:51 +00:00
1 parent 38ef9ccad3
commit 227dc9e7e8
3 files changed
+8 -4

No files matched your search

@@ -6,6 +6,8 @@ import type { HardwareCheckStats } from "@/Types/Monitor";
import { useMemo } from "react"; import { useMemo } from "react";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery"; import useMediaQuery from "@mui/material/useMediaQuery";
const formatPercent = (value: number) => `${(value * 100).toFixed(0)}%`;
const formatTemp = (value: number) => `${value.toFixed(0)}°C`;
const getChartConfigs = (theme: any, checks: HardwareCheckStats[], t: any) => { const getChartConfigs = (theme: any, checks: HardwareCheckStats[], t: any) => {
return [ return [
@@ -16,6 +18,7 @@ const getChartConfigs = (theme: any, checks: HardwareCheckStats[], t: any) => {
strokeColor: theme.palette.primary.main, strokeColor: theme.palette.primary.main,
gradientStartColor: theme.palette.primary.main, gradientStartColor: theme.palette.primary.main,
yDomain: [0, 1], yDomain: [0, 1],
yAxisFormatter: formatPercent,
idx: null, idx: null,
}, },
{ {
@@ -25,6 +28,7 @@ const getChartConfigs = (theme: any, checks: HardwareCheckStats[], t: any) => {
strokeColor: theme.palette.success.main, strokeColor: theme.palette.success.main,
gradientStartColor: theme.palette.success.main, gradientStartColor: theme.palette.success.main,
yDomain: [0, 1], yDomain: [0, 1],
yAxisFormatter: formatPercent,
idx: null, idx: null,
}, },
{ {
@@ -34,6 +38,7 @@ const getChartConfigs = (theme: any, checks: HardwareCheckStats[], t: any) => {
strokeColor: theme.palette.error.main, strokeColor: theme.palette.error.main,
gradientStartColor: theme.palette.error.main, gradientStartColor: theme.palette.error.main,
yDomain: [0, 150], yDomain: [0, 150],
yAxisFormatter: formatTemp,
idx: null, idx: null,
}, },
...(checks[0]?.disks?.map((_, idx) => ({ ...(checks[0]?.disks?.map((_, idx) => ({
@@ -43,6 +48,7 @@ const getChartConfigs = (theme: any, checks: HardwareCheckStats[], t: any) => {
strokeColor: theme.palette.warning.main, strokeColor: theme.palette.warning.main,
gradientStartColor: theme.palette.warning.main, gradientStartColor: theme.palette.warning.main,
yDomain: [0, 1], yDomain: [0, 1],
yAxisFormatter: formatPercent,
idx, idx,
})) || []), })) || []),
]; ];
@@ -88,6 +94,7 @@ export const InfraDetailsCharts = ({
gradientStartColor={config.gradientStartColor} gradientStartColor={config.gradientStartColor}
gradientEndColor="#ffffff" gradientEndColor="#ffffff"
strokeColor={config.strokeColor} strokeColor={config.strokeColor}
yAxisFormatter={config.yAxisFormatter}
/> />
</Grid> </Grid>
); );
@@ -7,8 +7,7 @@ import { useMemo } from "react";
import { useTheme } from "@mui/material/styles"; import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery"; import useMediaQuery from "@mui/material/useMediaQuery";
const formatBytesToMB = (value: number) => const formatBytesToMB = (value: number) => `${(value / (1024 * 1024)).toFixed(2)} MB`;
`${(value / (1024 * 1024)).toFixed(2)} MB`;
interface ChartConfig { interface ChartConfig {
title: string; title: string;
@@ -41,8 +41,6 @@ const InfrastructureDetails = () => {
{ refreshInterval: 10000, keepPreviousData: true } { refreshInterval: 10000, keepPreviousData: true }
); );
console.log(monitorDetailsData);
const monitor = monitorDetailsData?.monitor; const monitor = monitorDetailsData?.monitor;
const monitorStats = monitorDetailsData?.monitorStats ?? null; const monitorStats = monitorDetailsData?.monitorStats ?? null;
const stats = monitorDetailsData?.stats; const stats = monitorDetailsData?.stats;