diff --git a/src/components/AttendanceComparison.tsx b/src/components/AttendanceComparison.tsx index 9a296c2c..bb8251ac 100644 --- a/src/components/AttendanceComparison.tsx +++ b/src/components/AttendanceComparison.tsx @@ -6,9 +6,9 @@ import { YAxis, CartesianGrid, Tooltip, - Legend, ResponsiveContainer, LabelList, + Legend, } from 'recharts'; import { Radio, @@ -29,7 +29,6 @@ import NoDataFound from './common/NoDataFound'; import { useDirection } from '../hooks/useDirection'; import { AttendanceAPILimit } from '../../app.config'; import { telemetryFactory } from '@/utils/telemetry'; -import { Rtt } from '@mui/icons-material'; interface AttendanceComparisonProps { blockName: string; @@ -39,7 +38,7 @@ interface Cohort { cohortId: string; cohortType: string; name: string; - status?:string + status?: string; } interface AttendanceResult { @@ -51,7 +50,6 @@ interface AttendanceResult { interface AttendanceResponse { responseCode?: number; - // statusCode?: number; message: string; data: { result: { @@ -88,7 +86,7 @@ const AttendanceComparison: React.FC = ({ cdata: [], }, edata: { - id: 'center-type-selection: '+event.target.value, + id: 'center-type-selection: ' + event.target.value, type: Telemetry.CLICK, subtype: '', pageid: 'dashboard', @@ -140,54 +138,40 @@ const AttendanceComparison: React.FC = ({ }, [store?.cohorts, scope, centerType]); const data = - store?.cohorts - ?.filter( - (pair: Cohort) => - pair?.cohortType === centerType && pair?.status === Status.ACTIVE - ) - .map((pair: Cohort) => ({ - name: toPascalCase(pair?.name), - Attendance: Number(attendanceData[pair?.cohortId]) || 0, - })) || []; - // const data = - // store?.cohorts - // ?.filter((pair: Cohort) => pair?.cohortType === centerType) - // .map((pair: Cohort) => ({ - // name: toPascalCase(pair?.name), - // Attendance: Number(attendanceData[pair?.cohortId]) || 0, - // })) || []; - - const YAxisLabel = (value: any) => { - let maxLength = 25; - value = toPascalCase(value); - - if (isMobile) { - maxLength = 6; - } - - const formattedValue = - value.length > maxLength ? `${value.slice(0, maxLength)}...` : value; - - // Return a plain string, not a React element - return formattedValue; - }; + store?.cohorts + ?.filter( + (pair: Cohort) => + pair?.cohortType === centerType && pair?.status === Status.ACTIVE + ) + .map((pair: Cohort) => ({ + name: toPascalCase(pair?.name), + Attendance: Number(attendanceData[pair?.cohortId]) || 0, + })) || []; const renderCustomLabel = (props: any) => { const { x, y, width, height, value } = props; - const offsetX = width < 40 ? width + 5 : width / 2; // Adjust position based on bar width return ( - - {value}% - + + + + {value}% + + ); }; @@ -222,95 +206,53 @@ const AttendanceComparison: React.FC = ({ onChange={handleCenterTypeChange} > - } + control={} label={t('CENTERS.REGULAR')} - sx={{ - '& .MuiFormControlLabel-label': { - color: theme.palette.warning['300'], - fontSize: '18px', - }, - }} /> - } + control={} label={t('CENTERS.REMOTE')} - sx={{ - '& .MuiFormControlLabel-label': { - color: theme.palette.warning['300'], - fontSize: '18px', - }, - }} /> {data?.length > 0 && ( <> - + {centerType === CenterType.REMOTE ? t('DASHBOARD.REMOTE_AVERAGE_ATTENDANCE') : t('DASHBOARD.REGULAR_AVERAGE_ATTENDANCE')} : {averageAttendance.toFixed(2)}% - + - + `${value}%`} height={0} reversed={isRTL ? true : false} domain={[0, 100]} + /> - `${value}%`} /> = ({ barSize={40} radius={2} > - + @@ -339,16 +285,11 @@ const AttendanceComparison: React.FC = ({ domain={[0, 100]} reversed={isRTL ? true : false} /> - `${value}%`} /> + `${value}%`} /> - - - {t('DASHBOARD.ATTENDANCE')} - - )} @@ -357,4 +298,4 @@ const AttendanceComparison: React.FC = ({ ); }; -export default AttendanceComparison; +export default AttendanceComparison; \ No newline at end of file