import { useCallback, useState } from "react"; // recharts import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Sector } from "recharts"; // types import { IUserStateDistribution } from "types"; // constants import { STATE_GROUP_COLORS } from "constants/state"; type Props = { groupedIssues: IUserStateDistribution[] | undefined; }; export const IssuesPieChart: React.FC = ({ groupedIssues }) => { const [activeIndex, setActiveIndex] = useState(0); const onPieEnter = useCallback( (_: any, index: number) => { setActiveIndex(index); }, [setActiveIndex] ); const renderActiveShape = ({ cx, cy, midAngle, innerRadius, outerRadius, startAngle, endAngle, fill, payload, value, }: any) => { const RADIAN = Math.PI / 180; const sin = Math.sin(-RADIAN * midAngle); const cos = Math.cos(-RADIAN * midAngle); const sx = cx + (outerRadius + 10) * cos; const sy = cy + (outerRadius + 10) * sin; const mx = cx + (outerRadius + 30) * cos; const my = cy + (outerRadius + 30) * sin; const ex = mx + (cos >= 0 ? 1 : -1) * 22; const ey = my; const textAnchor = cos >= 0 ? "start" : "end"; return ( {payload.state_group} = 0 ? 1 : -1) * 12} y={ey} textAnchor={textAnchor} fill="#333"> {value} issues ); }; return (

Issues by States

{groupedIssues?.map((cell) => ( ))}
); };