mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
fix display of values under 1 GB in disk usage chart (closes #261)
This commit is contained in:
@@ -27,6 +27,11 @@ export default memo(function DiskChart({
|
|||||||
const { yAxisWidth, updateYAxisWidth } = useYAxisWidth()
|
const { yAxisWidth, updateYAxisWidth } = useYAxisWidth()
|
||||||
const { _ } = useLingui()
|
const { _ } = useLingui()
|
||||||
|
|
||||||
|
// round to nearest GB
|
||||||
|
if (diskSize >= 100) {
|
||||||
|
diskSize = Math.round(diskSize)
|
||||||
|
}
|
||||||
|
|
||||||
if (chartData.systemStats.length === 0) {
|
if (chartData.systemStats.length === 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@@ -413,11 +413,7 @@ export default function SystemDetail({ name }: { name: string }) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<ChartCard empty={dataEmpty} grid={grid} title={t`Disk Usage`} description={t`Usage of root partition`}>
|
<ChartCard empty={dataEmpty} grid={grid} title={t`Disk Usage`} description={t`Usage of root partition`}>
|
||||||
<DiskChart
|
<DiskChart chartData={chartData} dataKey="stats.du" diskSize={systemStats.at(-1)?.stats.d ?? NaN} />
|
||||||
chartData={chartData}
|
|
||||||
dataKey="stats.du"
|
|
||||||
diskSize={Math.round(systemStats.at(-1)?.stats.d ?? NaN)}
|
|
||||||
/>
|
|
||||||
</ChartCard>
|
</ChartCard>
|
||||||
|
|
||||||
<ChartCard
|
<ChartCard
|
||||||
@@ -497,7 +493,7 @@ export default function SystemDetail({ name }: { name: string }) {
|
|||||||
<DiskChart
|
<DiskChart
|
||||||
chartData={chartData}
|
chartData={chartData}
|
||||||
dataKey={`stats.efs.${extraFsName}.du`}
|
dataKey={`stats.efs.${extraFsName}.du`}
|
||||||
diskSize={Math.round(systemStats.at(-1)?.stats.efs?.[extraFsName].d ?? NaN)}
|
diskSize={systemStats.at(-1)?.stats.efs?.[extraFsName].d ?? NaN}
|
||||||
/>
|
/>
|
||||||
</ChartCard>
|
</ChartCard>
|
||||||
<ChartCard
|
<ChartCard
|
||||||
|
@@ -272,7 +272,7 @@ export const getSizeAndUnit = (n: number, isGigabytes = true) => {
|
|||||||
} else if (sizeInGB >= 1) {
|
} else if (sizeInGB >= 1) {
|
||||||
return { v: sizeInGB, u: " GB" }
|
return { v: sizeInGB, u: " GB" }
|
||||||
}
|
}
|
||||||
return { v: n, u: " MB" }
|
return { v: isGigabytes ? sizeInGB * 1_000 : n, u: " MB" }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const chartMargin = { top: 12 }
|
export const chartMargin = { top: 12 }
|
||||||
|
Reference in New Issue
Block a user