Fixed mobile layout in Pie Chart and in table

This commit is contained in:
Luis-Hebendanz
2023-08-14 15:56:31 +02:00
parent 362379cdac
commit b112969d87
3 changed files with 30 additions and 14 deletions

View File

@@ -194,9 +194,9 @@ function EnhancedTableToolbar(props: EnhancedTableToolbarProps) {
).length; ).length;
return [ return [
{ name: "Online", value: online, color: "#2E7D32" }, { name: "Online", value: online, color: theme.palette.success.main },
{ name: "Offline", value: offline, color: "#db3927" }, { name: "Offline", value: offline, color: theme.palette.error.main },
{ name: "Pending", value: pending, color: "#FFBB28" }, { name: "Pending", value: pending, color: theme.palette.warning.main },
]; ];
}, [tableData]); }, [tableData]);
@@ -230,7 +230,7 @@ function EnhancedTableToolbar(props: EnhancedTableToolbarProps) {
height: 110, height: 110,
backgroundColor: hexRgb(pieItem.color, { backgroundColor: hexRgb(pieItem.color, {
format: "css", format: "css",
alpha: 0.18, alpha: 0.25,
}), }),
}} }}
> >
@@ -338,7 +338,7 @@ function EnhancedTableToolbar(props: EnhancedTableToolbarProps) {
<Grid2 <Grid2
key="PieChart" key="PieChart"
lg={6} lg={6}
sm={12} xs={12}
display="flex" display="flex"
justifyContent="center" justifyContent="center"
alignItems="center" alignItems="center"
@@ -353,7 +353,7 @@ function EnhancedTableToolbar(props: EnhancedTableToolbarProps) {
key="CardStack" key="CardStack"
lg={6} lg={6}
display="flex" display="flex"
sx={{ display: { lg: "flex", sm: "none" } }} sx={{ display: { lg: "flex", xs: "none" } }}
> >
{cardStack} {cardStack}
</Grid2> </Grid2>
@@ -426,6 +426,10 @@ export interface NodeTableProps {
export default function NodeTable(props: NodeTableProps) { export default function NodeTable(props: NodeTableProps) {
let { tableData } = props; let { tableData } = props;
const theme = useTheme();
const is_xs = useMediaQuery(theme.breakpoints.only("xs"));
const [order, setOrder] = React.useState<Order>("asc"); const [order, setOrder] = React.useState<Order>("asc");
const [orderBy, setOrderBy] = React.useState<keyof TableData>("status"); const [orderBy, setOrderBy] = React.useState<keyof TableData>("status");
const [selected, setSelected] = React.useState<string | undefined>(undefined); const [selected, setSelected] = React.useState<string | undefined>(undefined);
@@ -479,7 +483,7 @@ export default function NodeTable(props: NodeTableProps) {
); );
return ( return (
<Paper elevation={1} sx={{ margin: 5 }}>
<Box sx={{ width: "100%" }}> <Box sx={{ width: "100%" }}>
<Paper sx={{ width: "100%", mb: 2 }}> <Paper sx={{ width: "100%", mb: 2 }}>
<EnhancedTableToolbar <EnhancedTableToolbar
@@ -542,6 +546,7 @@ export default function NodeTable(props: NodeTableProps) {
{/* TODO: This creates the error Warning: Prop `id` did not match. Server: ":RspmmcqH1:" Client: ":R3j6qpj9H1:" */} {/* TODO: This creates the error Warning: Prop `id` did not match. Server: ":RspmmcqH1:" Client: ":R3j6qpj9H1:" */}
<TablePagination <TablePagination
rowsPerPageOptions={[5, 10, 25]} rowsPerPageOptions={[5, 10, 25]}
labelRowsPerPage={is_xs ? "Rows" : "Rows per page:"}
component="div" component="div"
count={tableData.length} count={tableData.length}
rowsPerPage={rowsPerPage} rowsPerPage={rowsPerPage}
@@ -551,6 +556,6 @@ export default function NodeTable(props: NodeTableProps) {
/> />
</Paper> </Paper>
</Box> </Box>
</Paper>
); );
} }

View File

@@ -37,6 +37,20 @@ export default function NodePieChart(props: Props) {
dataKey="value" dataKey="value"
nameKey="name" nameKey="name"
label={showLabels} label={showLabels}
legendType="circle"
cx="50%"
cy="50%"
startAngle={0}
endAngle={360}
paddingAngle={0}
labelLine={true}
hide={false}
minAngle={0}
isAnimationActive={true}
animationBegin={0}
animationDuration={1000}
animationEasing="ease-in"
blendStroke={true}
> >
{data.map((entry, index) => ( {data.map((entry, index) => (
<Cell key={`cell-${index}`} fill={entry.color} /> <Cell key={`cell-${index}`} fill={entry.color} />

View File

@@ -4,15 +4,12 @@ import NodeList from "./NodeList";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import { tableData } from "@/data/nodeData"; import { tableData } from "@/data/nodeData";
import { StrictMode } from "react";
export default function Page() { export default function Page() {
return ( return (
<Box <StrictMode>
sx={{ backgroundColor: "#e9ecf5", height: "100%", width: "100%" }}
display="inline-block"
id="rootBox"
>
<NodeList tableData={tableData} /> <NodeList tableData={tableData} />
</Box> </StrictMode>
); );
} }