-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing the custom tables with DataGrids
- Loading branch information
1 parent
81831aa
commit 1b1a8aa
Showing
4 changed files
with
173 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import * as React from "react"; | ||
import Box from "@mui/material/Box"; | ||
import { DataGrid } from "@mui/x-data-grid"; | ||
import { Card, CardContent, Typography } from "@mui/material"; | ||
import styled from "@emotion/styled"; | ||
|
||
const CellContent = styled.span` | ||
font-weight: ${(props) => (props.isBold ? "bold" : "normal")}; | ||
`; | ||
|
||
const columns = [ | ||
{ field: "id", headerName: "Index", type: "number", width: 90 }, | ||
{ | ||
field: "name", | ||
headerName: "Feature Name", | ||
width: 200, | ||
editable: true, | ||
valueGetter: (params) => | ||
`${params.row.name} ${params.row.target === "1" ? "(target)" : ""}`, | ||
renderCell: (params) => { | ||
const isBold = params.row.target === "1"; | ||
return <CellContent isBold={isBold}>{params.value}</CellContent>; | ||
}, | ||
}, | ||
{ | ||
field: "type", | ||
headerName: "Type", | ||
width: 100, | ||
editable: true, | ||
}, | ||
{ | ||
field: "distinct", | ||
headerName: "Distinct values", | ||
type: "number", | ||
width: 110, | ||
editable: true, | ||
}, | ||
{ | ||
field: "missing", | ||
headerName: "Missing values", | ||
type: "number", | ||
width: 110, | ||
editable: true, | ||
}, | ||
]; | ||
|
||
const FeatureTable = ({ data }) => { | ||
// Define the rows for the grid | ||
const rows = data.map((feature) => { | ||
const id = feature.index; // Rename index to id | ||
return { | ||
id, | ||
...Object.keys(feature).reduce((acc, key) => { | ||
acc[key] = feature[key]; | ||
return acc; | ||
}, {}), | ||
}; | ||
}); | ||
|
||
return ( | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h4" mb={6}> | ||
{data.length + " Features"} | ||
</Typography> | ||
<Box sx={{ width: "100%" }}> | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
getRowId={(row) => row.index} | ||
sortModel={[ | ||
{ | ||
field: "id", | ||
sort: "asc", | ||
}, | ||
]} | ||
initialState={{ | ||
pagination: { | ||
paginationModel: { | ||
pageSize: 10, | ||
}, | ||
}, | ||
}} | ||
pageSizeOptions={[10, 20, 50, 100]} | ||
/> | ||
</Box> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default FeatureTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as React from "react"; | ||
import Box from "@mui/material/Box"; | ||
import { DataGrid } from "@mui/x-data-grid"; | ||
import { Card, CardContent, Typography } from "@mui/material"; | ||
|
||
const columns = [ | ||
{ | ||
field: "quality", | ||
headerName: "Quality Name", | ||
width: 400, | ||
editable: true, | ||
}, | ||
{ | ||
field: "value", | ||
headerName: "Value", | ||
width: 100, | ||
editable: true, | ||
type: "number", | ||
}, | ||
]; | ||
|
||
const QualityTable = ({ data }) => { | ||
// Define the rows for the grid | ||
const rows = Object.keys(data).map((key) => ({ | ||
id: key, | ||
quality: key, | ||
value: data[key], | ||
})); | ||
|
||
return ( | ||
<Card> | ||
<CardContent> | ||
<Typography variant="h4" mb={6}> | ||
{Object.keys(data).length + " Qualities (meta-features)"} | ||
</Typography> | ||
<Box sx={{ width: "100%" }}> | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
initialState={{ | ||
pagination: { | ||
paginationModel: { | ||
pageSize: 5, | ||
}, | ||
}, | ||
}} | ||
pageSizeOptions={[5, 10, 20, 50, 100]} | ||
/> | ||
</Box> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default QualityTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters