mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
use precise number for max mem in memory chart
This commit is contained in:
@@ -1,7 +1,13 @@
|
|||||||
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts'
|
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts'
|
||||||
|
|
||||||
import { ChartContainer, ChartTooltip, ChartTooltipContent } from '@/components/ui/chart'
|
import { ChartContainer, ChartTooltip, ChartTooltipContent } from '@/components/ui/chart'
|
||||||
import { chartTimeData, cn, formatShortDate, useYaxisWidth } from '@/lib/utils'
|
import {
|
||||||
|
chartTimeData,
|
||||||
|
cn,
|
||||||
|
formatShortDate,
|
||||||
|
toFixedWithoutTrailingZeros,
|
||||||
|
useYaxisWidth,
|
||||||
|
} from '@/lib/utils'
|
||||||
import { useMemo, useRef } from 'react'
|
import { useMemo, useRef } from 'react'
|
||||||
// import Spinner from '../spinner'
|
// import Spinner from '../spinner'
|
||||||
import { useStore } from '@nanostores/react'
|
import { useStore } from '@nanostores/react'
|
||||||
@@ -21,10 +27,10 @@ export default function MemChart({
|
|||||||
|
|
||||||
const yAxisSet = useMemo(() => yAxisWidth !== 180, [yAxisWidth])
|
const yAxisSet = useMemo(() => yAxisWidth !== 180, [yAxisWidth])
|
||||||
|
|
||||||
const totalMem = useMemo(() => {
|
// const totalMem = useMemo(() => {
|
||||||
const maxMem = Math.ceil(systemData[0]?.stats.m)
|
// const maxMem = Math.ceil(systemData[0]?.stats.m)
|
||||||
return maxMem > 2 && maxMem % 2 !== 0 ? maxMem + 1 : maxMem
|
// return maxMem > 2 && maxMem % 2 !== 0 ? maxMem + 1 : maxMem
|
||||||
}, [systemData])
|
// }, [systemData])
|
||||||
|
|
||||||
// if (!systemData.length || !ticks.length) {
|
// if (!systemData.length || !ticks.length) {
|
||||||
// return <Spinner />
|
// return <Spinner />
|
||||||
@@ -49,7 +55,7 @@ export default function MemChart({
|
|||||||
<CartesianGrid vertical={false} />
|
<CartesianGrid vertical={false} />
|
||||||
<YAxis
|
<YAxis
|
||||||
// use "ticks" instead of domain / tickcount if need more control
|
// use "ticks" instead of domain / tickcount if need more control
|
||||||
domain={[0, totalMem]}
|
domain={[0, () => toFixedWithoutTrailingZeros(systemData.at(-1)?.stats.m ?? 0.04, 1)]}
|
||||||
width={yAxisWidth}
|
width={yAxisWidth}
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
axisLine={false}
|
axisLine={false}
|
||||||
|
Reference in New Issue
Block a user