-
Notifications
You must be signed in to change notification settings - Fork 5
/
OverviewSparkline.tsx
58 lines (55 loc) · 1.45 KB
/
OverviewSparkline.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Box, LoadingOverlay, Space, Text } from "@mantine/core"
import React from "react"
import { type AxisDomain } from "recharts/types/util/types"
import chartLoaderAnimation from "./chart-loader.json"
import PortalLoader from "~/components/PortalLoader"
import Sparkline from "~/components/Sparkline"
import { ChartData } from "~/types/global"
type OverviewSparklineProps = {
label?: string
title?: string
sparklineData: ChartData[]
isLoading?: boolean
customYAxisDomain?: AxisDomain
commifyLabelValue?: boolean
}
export const OverviewSparkline = ({
label = "relays",
commifyLabelValue,
title,
sparklineData,
isLoading,
customYAxisDomain,
}: OverviewSparklineProps) => {
const height = 350
return (
<Box h={`${height}px`} pos="relative">
{title ? (
<Text fw="600" fz="md" mb="lg">
{title}
</Text>
) : (
<Space mb="lg" />
)}
<LoadingOverlay
loaderProps={{
children: <PortalLoader loaderAnimation={chartLoaderAnimation} />,
}}
overlayProps={{ opacity: 0.01 }}
visible={!!isLoading}
/>
{!isLoading ? (
<Sparkline
commifyLabelValue={commifyLabelValue}
customYAxisDomain={customYAxisDomain}
data={sparklineData}
height={height}
label={label}
xAxisDataKey="date"
yAxisDataKey="val"
/>
) : null}
</Box>
)
}
export default OverviewSparkline