import PropTypes from "prop-types"; import { useTheme } from "@mui/material"; import { ResponsiveContainer, RadialBarChart, RadialBar, Cell } from "recharts"; const ResponseGaugeChart = ({ avgResponseTime }) => { const theme = useTheme(); let max = 1000; // max ms const data = [ { response: max, fill: "transparent", background: false }, { response: avgResponseTime, background: true }, ]; let responseTime = Math.floor(avgResponseTime); let responseProps = responseTime <= 200 ? { category: "Excellent", main: theme.palette.success.main, bg: theme.palette.success.contrastText, } : responseTime <= 500 ? { category: "Fair", main: theme.palette.success.main, bg: theme.palette.success.contrastText, } : responseTime <= 600 ? { category: "Acceptable", main: theme.palette.warning.main, bg: theme.palette.warning.dark, } : { category: "Poor", main: theme.palette.error.main, bg: theme.palette.error.light, }; return ( low high {responseProps.category} {responseTime} ms ); }; ResponseGaugeChart.propTypes = { avgResponseTime: PropTypes.number.isRequired, }; export default ResponseGaugeChart;