import { memo, useState } from "react"; import { useTheme } from "@mui/material"; import { ResponsiveContainer, BarChart, XAxis, Bar, Cell } from "recharts"; import PropTypes from "prop-types"; import CustomLabels from "./CustomLabels"; const DownBarChart = memo(({ monitor, type, onBarHover }) => { const theme = useTheme(); const [chartHovered, setChartHovered] = useState(false); const [hoveredBarIndex, setHoveredBarIndex] = useState(null); return ( { setChartHovered(true); onBarHover({ time: null, totalChecks: 0 }); }} onMouseLeave={() => { setChartHovered(false); setHoveredBarIndex(null); onBarHover(null); }} > } /> {monitor.groupedDownChecks.map((entry, index) => { return ( { setHoveredBarIndex(index); onBarHover(entry); }} onMouseLeave={() => { setHoveredBarIndex(null); onBarHover({ time: null, totalChecks: 0 }); }} /> ); })} ); }); DownBarChart.displayName = "DownBarChart"; DownBarChart.propTypes = { monitor: PropTypes.shape({ groupedDownChecks: PropTypes.arrayOf(PropTypes.object), }), type: PropTypes.string, onBarHover: PropTypes.func, }; export default DownBarChart;