-
-
Notifications
You must be signed in to change notification settings - Fork 535
Expand file tree
/
Copy pathTS.tsx
More file actions
89 lines (84 loc) · 2.04 KB
/
Copy pathTS.tsx
File metadata and controls
89 lines (84 loc) · 2.04 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { useMemo } from 'react';
import {
MaterialReactTable,
useMaterialReactTable,
type MRT_ColumnDef,
} from '@glebcha/material-react-table';
import { useTheme } from '@mui/material/styles';
import { LineChart } from '@mui/x-charts/LineChart';
import { data, type Person } from './makeData';
const Example = () => {
const theme = useTheme();
const columns = useMemo<MRT_ColumnDef<Person>[]>(
//column definitions...
() => [
{
accessorKey: 'id',
header: 'ID',
size: 50,
},
{
accessorKey: 'firstName',
header: 'First Name',
},
{
accessorKey: 'middleName',
header: 'Middle Name',
},
{
accessorKey: 'lastName',
header: 'Last Name',
},
],
[],
//end
);
const table = useMaterialReactTable({
columns,
data,
initialState: { expanded: { 0: true } },
muiTableBodyRowProps: {
sx: {
'.Mui-TableBodyCell-DetailPanel': {
backgroundColor:
theme.palette.mode === 'dark'
? theme.palette.grey[900]
: theme.palette.grey[100],
},
},
},
renderDetailPanel: ({ row }) => (
<LineChart
xAxis={[
{
data: row.original.gamesPlayed,
label: 'Games Played',
valueFormatter: (value) => `#${value}`,
tickLabelInterval: (value) => value % 1 === 0,
},
]}
yAxis={[{ min: 0, max: 60 }]}
series={[
{
color: theme.palette.primary.dark,
data: row.original.points,
label: 'Points',
},
{
color: theme.palette.secondary.main,
data: row.original.assists,
label: 'Assists',
},
{
color: theme.palette.error.main,
data: row.original.turnovers,
label: 'Turnovers',
},
]}
height={250}
/>
),
});
return <MaterialReactTable table={table} />;
};
export default Example;