fix display of values under 1 GB in disk usage chart (closes #261)

This commit is contained in:
Henry Dollman
2024-11-06 13:52:35 -05:00
parent 233349fb2a
commit b5ed7cd555
3 changed files with 8 additions and 7 deletions

View File

@@ -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
} }

View File

@@ -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

View File

@@ -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 }