mirror of
https://github.com/diced/zipline.git
synced 2025-05-10 18:05:54 +02:00
38 lines
1,022 B
TypeScript
Executable file
38 lines
1,022 B
TypeScript
Executable file
import { bytes } from '@/lib/bytes';
|
|
import { Metric } from '@/lib/db/models/metric';
|
|
import { Paper, Title } from '@mantine/core';
|
|
import dynamic from 'next/dynamic';
|
|
|
|
const Line = dynamic(() => import('@ant-design/plots').then(({ Line }) => Line), { ssr: false });
|
|
|
|
export default function StorageGraph({ metrics }: { metrics: Metric[] }) {
|
|
return (
|
|
<Paper radius='sm' withBorder p='sm' mt='md'>
|
|
<Title order={3} mb='sm'>
|
|
Storage Used
|
|
</Title>
|
|
|
|
<Line
|
|
data={metrics.map((metric) => ({
|
|
date: metric.createdAt,
|
|
storage: metric.data.storage,
|
|
}))}
|
|
xField='date'
|
|
yField='storage'
|
|
xAxis={{
|
|
type: 'time',
|
|
mask: 'YYYY-MM-DD HH:mm:ss',
|
|
}}
|
|
yAxis={{
|
|
label: {
|
|
formatter: (v) => bytes(Number(v)),
|
|
},
|
|
}}
|
|
tooltip={{
|
|
formatter: (v) => ({ name: 'Storage Used', value: bytes(Number(v.storage)) }),
|
|
}}
|
|
smooth
|
|
/>
|
|
</Paper>
|
|
);
|
|
}
|