Fix tooltip and proptypes
This commit is contained in:
1 parent
69f7cf2ab1
commit
e7cf127fde
1 file changed
+9
-16
@@ -20,6 +20,9 @@ const CustomToolTip = ({ active, payload, label }) => {
|
|||||||
const dateFormat = label?.length === 10 ? "YYYY-MM-DD" : "YYYY-MM-DD-HH";
|
const dateFormat = label?.length === 10 ? "YYYY-MM-DD" : "YYYY-MM-DD-HH";
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
if (active && payload && payload.length) {
|
if (active && payload && payload.length) {
|
||||||
|
const responseTime = payload[0]?.payload?.originalAvgResponseTime
|
||||||
|
? payload[0]?.payload?.originalAvgResponseTime
|
||||||
|
: (payload[0]?.payload?.avgResponseTime ?? 0);
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className="area-tooltip"
|
className="area-tooltip"
|
||||||
@@ -73,7 +76,7 @@ const CustomToolTip = ({ active, payload, label }) => {
|
|||||||
Response Time
|
Response Time
|
||||||
</Typography>{" "}
|
</Typography>{" "}
|
||||||
<Typography component="span">
|
<Typography component="span">
|
||||||
{Math.floor(payload[0].payload.originalAvgResponseTime)}
|
{Math.floor(responseTime)}
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{ opacity: 0.8 }}
|
sx={{ opacity: 0.8 }}
|
||||||
@@ -95,15 +98,16 @@ CustomToolTip.propTypes = {
|
|||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
payload: PropTypes.arrayOf(
|
payload: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
|
value: PropTypes.number,
|
||||||
payload: PropTypes.shape({
|
payload: PropTypes.shape({
|
||||||
_id: PropTypes.string.isRequired, // Add this line to validate _id
|
_id: PropTypes.string,
|
||||||
originalResponseTime: PropTypes.number.isRequired,
|
avgResponseTime: PropTypes.number,
|
||||||
}).isRequired,
|
originalAvgResponseTime: PropTypes.number,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||||
};
|
};
|
||||||
|
|
||||||
const CustomTick = ({ x, y, payload, index }) => {
|
const CustomTick = ({ x, y, payload, index }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@@ -215,15 +219,4 @@ MonitorDetailsAreaChart.propTypes = {
|
|||||||
checks: PropTypes.array,
|
checks: PropTypes.array,
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomToolTip.propTypes = {
|
|
||||||
active: PropTypes.bool,
|
|
||||||
payload: PropTypes.arrayOf(
|
|
||||||
PropTypes.shape({
|
|
||||||
payload: PropTypes.shape({
|
|
||||||
originalAvgResponseTime: PropTypes.number,
|
|
||||||
}).isRequired,
|
|
||||||
})
|
|
||||||
),
|
|
||||||
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
||||||
};
|
|
||||||
export default MonitorDetailsAreaChart;
|
export default MonitorDetailsAreaChart;
|
||||||
Reference in new issue
Block a user