import PropTypes from "prop-types"; import { useTheme } from "@mui/material"; import { ResponsiveContainer, RadialBarChart, RadialBar, Cell } from "recharts"; import { useTranslation } from "react-i18next"; const ResponseGaugeChart = ({ avgResponseTime }) => { const theme = useTheme(); const { t } = useTranslation(); 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.lowContrast, } : { category: "Poor", main: theme.palette.error.main, bg: theme.palette.error.contrastText, }; return ( {t("low")} {t("high")} {responseProps.category} {responseTime} ms ); }; ResponseGaugeChart.propTypes = { avgResponseTime: PropTypes.number.isRequired, }; export default ResponseGaugeChart;