import React from "react"; import { XAxis, YAxis, Tooltip, AreaChart, Area, ReferenceLine, TooltipProps} from "recharts"; //types import { IIssue } from "types"; import { NameType, ValueType } from "recharts/types/component/DefaultTooltipContent"; // helper import { getDatesInRange, renderShortNumericDateFormat } from "helpers/date-time.helper"; type Props = { issues: IIssue[]; start: string; end: string; }; const ProgressChart: React.FC = ({ issues, start, end }) => { const startDate = new Date(start); const endDate = new Date(end); const getChartData = () => { const dateRangeArray = getDatesInRange(startDate, endDate); let count = 0; const dateWiseData = dateRangeArray.map((d) => { const current = d.toISOString().split("T")[0]; const total = issues.length; const currentData = issues.filter( (i) => i.completed_at && i.completed_at.toString().split("T")[0] === current ); count = currentData ? currentData.length + count : count; return { currentDate: renderShortNumericDateFormat(current), currentDateData: currentData, pending: new Date(current) < new Date() ? total - count : null, }; }); return dateWiseData; }; const CustomTooltip = ({ active, payload }: TooltipProps) => { if (active && payload && payload.length) { console.log(payload[0].payload.currentDate); return (

{payload[0].payload.currentDate}

); } return null; }; const ChartData = getChartData(); return (
} />
); }; export default ProgressChart;