import { PieChart, Pie, Cell } from "recharts"; interface Ring { color: string; value: number; } interface Card { percent: number; rings: Ring[]; } interface MultiRingCircularProgressProps { card: Card; hoveredIndex: number | null; onHover: (index: number | null) => void; } export default function MultiRingCircularProgress({ card, hoveredIndex, onHover }: MultiRingCircularProgressProps) { const { percent, rings } = card; // Create ring data with proper outer and inner radius calculations const ringData = rings.map((ring, index) => ({ ...ring, outerRadius: 110 - (index * 18), // Decrease by 18px for each ring innerRadius: 95 - (index * 18), // Decrease by 18px for each ring })); // When a ring is hovered, other rings become gray const getHoverColor = (ring: Ring, index: number) => { if (hoveredIndex === null) return ring.color; if (hoveredIndex === index) return ring.color; return "#d3d3d3"; // gray for non-hovered rings }; return (
onHover(null)} onClick={() => { console.log("hoveredIndex "); }} style={{ outline: "none", border: "none" }} tabIndex={-1} > {ringData.map((ring, index) => ( onHover(index)} onMouseLeave={() => onHover(null)} fill={getHoverColor(ring, index)} className="focus:outline-none focus:ring-0 focus:border-none" // pointerEvents={'none'} > ))} {percent}%
); }