/* * @Author: ZhaoYing * @Date: 2026-02-03 18:34:16 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-02-03 18:34:16 */ import { type FC, useRef, useEffect } from 'react' import { useTranslation } from 'react-i18next' import ReactEcharts from 'echarts-for-react'; import Loading from '@/components/Empty/Loading' import Empty from '@/components/Empty' import RbCard from '@/components/RbCard/Card' /** * Props for ActivationMetricsPieCard component * @property {Array>} chartData - Activation value distribution data * @property {boolean} loading - Loading state */ interface ActivationMetricsPieCardProps { chartData: Array>; loading: boolean; } const Colors = ['#155EEF', '#FFB048', '#FF5D34'] /** * ActivationMetricsPieCard Component * Displays activation value distribution as a donut chart with legend * Shows percentage distribution of different activation levels */ const ActivationMetricsPieCard: FC = ({ chartData, loading }) => { const { t } = useTranslation() const chartRef = useRef(null); const resizeScheduledRef = useRef(false) useEffect(() => { const handleResize = () => { if (chartRef.current && !resizeScheduledRef.current) { resizeScheduledRef.current = true requestAnimationFrame(() => { chartRef.current?.getEchartsInstance().resize(); resizeScheduledRef.current = false }); } } const resizeObserver = new ResizeObserver(handleResize) const chartElement = chartRef.current?.getEchartsInstance().getDom().parentElement if (chartElement) { resizeObserver.observe(chartElement) } return () => { resizeObserver.disconnect() } }, [chartData]) return ( {loading ? : !chartData || chartData.length === 0 ? : } ) } export default ActivationMetricsPieCard