-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLineChart.tsx
More file actions
43 lines (40 loc) · 957 Bytes
/
LineChart.tsx
File metadata and controls
43 lines (40 loc) · 957 Bytes
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
import { AgChartOptions, time } from 'ag-charts-community';
import { AgCharts } from 'ag-charts-react';
import { ReactElement, useMemo } from 'react';
import { theme } from '../constants/theme.ts';
import { useData } from '../hooks/useData.ts';
export default function LineChart(): ReactElement {
const data = useData();
const options: AgChartOptions = useMemo(() => {
return {
data,
title: {
text: 'Flight Time',
},
series: [
{
type: 'line',
xKey: 'date',
yKey: 'time',
yName: 'Flight Time',
},
],
axes: [
{
type: 'number',
position: 'left',
},
{
type: 'time',
position: 'bottom',
interval: { step: time.month },
label: {
format: '%b %Y',
},
},
],
theme,
};
}, [data]);
return <AgCharts options={options} />;
}