feat(members-time-sheet): enhance tooltip display with utilization status and color coding

This commit is contained in:
shancds
2025-05-26 16:25:12 +05:30
parent f68c72a92a
commit 85280c33d2

View File

@@ -83,17 +83,38 @@ const MembersTimeSheet = forwardRef<MembersTimeSheetRef>((_, ref) => {
}, },
tooltip: { tooltip: {
callbacks: { callbacks: {
label: function(context: any) { label: function (context: any) {
const idx = context.dataIndex; const idx = context.dataIndex;
const member = jsonData[idx]; const member = jsonData[idx];
const hours = member?.utilized_hours || '0.00'; const hours = member?.utilized_hours || '0.00';
const percent = member?.utilization_percent || '0.00'; const percent = parseFloat(member?.utilization_percent || '0.00');
const overUnder = member?.over_under_utilized_hours || '0.00'; const overUnder = member?.over_under_utilized_hours || '0.00';
let status = '';
let color = '';
if (percent < 90) {
status = 'Under';
} else if (percent <= 110) {
status = 'Optimal';
} else {
status = 'Over';
}
return [ return [
`${context.dataset.label}: ${hours} h`, `${context.dataset.label}: ${hours} h`,
`Utilization: ${percent}%`, `Utilization: ${percent}%`,
`Over/Under Utilized: ${overUnder} h` `${status} Utilized: ${overUnder} h`
]; ];
},
labelTextColor: function (context: any) {
const idx = context.dataIndex;
const member = jsonData[idx];
const utilization = parseFloat(member?.utilization_percent || '0');
if (utilization < 90) {
return '#FFB546';
} else if (utilization >= 90 && utilization <= 110) {
return '#B2EF9A';
} else {
return '#FE7173';
}
} }
} }
} }