import type React from 'react'; import { useTheme } from '@mui/material'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; interface ProgressComponentProps { active: number; stale: number; potentiallyStale: number; health: number; } export const ProjectHealthChart: React.FC = ({ active, stale, potentiallyStale, health, }) => { const theme = useTheme(); const gap = active === 0 || stale === 0 || active / stale > 30 || stale / active > 30 ? 0 : 10; const strokeWidth = 6; const radius = 50 - strokeWidth / 2; const circumference = 2 * Math.PI * radius; const gapAngle = (gap / circumference) * 360; const totalCount = active + stale; const activePercentage = totalCount === 0 ? 100 : (active / totalCount) * 100; const stalePercentage = totalCount === 0 ? 0 : (stale / totalCount) * 100; const potentiallyStalePercentage = active === 0 ? 0 : (potentiallyStale / totalCount) * 100; const activeLength = Math.max( (activePercentage / 100) * circumference - gap, 1, ); const staleLength = Math.max( (stalePercentage / 100) * circumference - gap, 1, ); const potentiallyStaleLength = Math.max( (potentiallyStalePercentage / 100) * circumference - gap, 1, ); const activeRotation = -90 + gapAngle / 2; const potentiallyStaleRotation = activeRotation + ((activeLength - potentiallyStaleLength) / circumference) * 360; const staleRotation = activeRotation + (activeLength / circumference) * 360 + gapAngle; const innerRadius = radius / 1.2; return ( Project Health Chart 0} show={ } /> 0} show={ } /> {health}% {active + stale} flags ); };