mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 17:59:28 +08:00
display TB in disk usage charts if value >= 1 TB
This commit is contained in:
@@ -50,7 +50,9 @@ export default function DiskChart({
|
|||||||
minTickGap={6}
|
minTickGap={6}
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
axisLine={false}
|
axisLine={false}
|
||||||
tickFormatter={(value) => updateYAxisWidth(value + ' GB')}
|
tickFormatter={(value) =>
|
||||||
|
updateYAxisWidth(toFixedFloat(getSizeVal(value), 2) + getSizeUnit(value))
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<XAxis
|
<XAxis
|
||||||
dataKey="created"
|
dataKey="created"
|
||||||
@@ -69,7 +71,9 @@ export default function DiskChart({
|
|||||||
content={
|
content={
|
||||||
<ChartTooltipContent
|
<ChartTooltipContent
|
||||||
labelFormatter={(_, data) => formatShortDate(data[0].payload.created)}
|
labelFormatter={(_, data) => formatShortDate(data[0].payload.created)}
|
||||||
contentFormatter={(item) => twoDecimalString(item.value) + ' GB'}
|
contentFormatter={({ value }) =>
|
||||||
|
twoDecimalString(getSizeVal(value)) + getSizeUnit(value)
|
||||||
|
}
|
||||||
indicator="line"
|
indicator="line"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@@ -290,3 +290,17 @@ export async function updateUserSettings() {
|
|||||||
console.log('create settings', e)
|
console.log('create settings', e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the unit of size (TB or GB) for a given size in gigabytes
|
||||||
|
* @param n size in gigabytes
|
||||||
|
* @returns unit of size (TB or GB)
|
||||||
|
*/
|
||||||
|
export const getSizeUnit = (n: number) => (n >= 1_000 ? ' TB' : ' GB')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of number in gigabytes if less than 1000, otherwise in terabytes
|
||||||
|
* @param n size in gigabytes
|
||||||
|
* @returns value in GB if less than 1000, otherwise value in TB
|
||||||
|
*/
|
||||||
|
export const getSizeVal = (n: number) => (n >= 1_000 ? n / 1_000 : n)
|
||||||
|
Reference in New Issue
Block a user