From c1418a423dd403d8c00ad9b2c607389afb355493 Mon Sep 17 00:00:00 2001 From: "Mac\\David" Date: Thu, 13 Jun 2024 17:04:31 +0800 Subject: [PATCH] bug fix --- .../ProgressByTeam/ProgressByTeam.tsx | 2 +- .../StaffUtilization/StaffUtilization.tsx | 31 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/ProgressByTeam/ProgressByTeam.tsx b/src/components/ProgressByTeam/ProgressByTeam.tsx index 09ac58a..efa2318 100644 --- a/src/components/ProgressByTeam/ProgressByTeam.tsx +++ b/src/components/ProgressByTeam/ProgressByTeam.tsx @@ -95,7 +95,7 @@ const ProgressByTeam: React.FC = () => { const manhourConsumptionPercentage = [] for (let i = 0; i < teamProjectResult.length; i++){ teamProjectResult[i].color = color[i] - projectNo.push(teamProjectResult[i].projectNo) + projectNo.push(teamProjectResult[i].projectCode) manhourConsumptionPercentage.push(teamProjectResult[i].manhourConsumptionPercentage) } setChartProjectName(projectNo) diff --git a/src/components/StaffUtilization/StaffUtilization.tsx b/src/components/StaffUtilization/StaffUtilization.tsx index 81bd660..58af1c1 100644 --- a/src/components/StaffUtilization/StaffUtilization.tsx +++ b/src/components/StaffUtilization/StaffUtilization.tsx @@ -326,7 +326,7 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { const result = new Array(weeklyPlannedList[0].length).fill(0); for (const arr of weeklyPlannedList) { for (let i = 0; i < arr.length; i++) { - result[i] += arr[i]; + result[i] = Number((result[i] + arr[i]).toFixed(2)); if (chartMax < result[i]) { chartMax = result[i] } @@ -334,7 +334,11 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { } setTeamTotalManhoursSpentPlanData(result) } - } + else { + const result = new Array(weekDates.length).fill(0); + setTeamTotalManhoursSpentPlanData(result) + } + } setTeamTotalManhoursSpentActualData(weeklyActualList); setTotalManHoursMaxValue(chartMax) } @@ -369,14 +373,17 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { const result = new Array(weeklyPlannedList[0].length).fill(0); for (const arr of weeklyPlannedList) { for (let i = 0; i < arr.length; i++) { - result[i] += arr[i]; + result[i] = Number((result[i] + arr[i]).toFixed(2)); if (chartMax < result[i]) { chartMax = result[i] } } } setTeamTotalManhoursSpentPlanData(result) - } + } else { + const result = new Array(weekDates.length).fill(0); + setTeamTotalManhoursSpentPlanData(result) + } } setTeamTotalManhoursSpentActualData(weeklyActualList); setTotalManHoursMaxValue(chartMax) @@ -567,7 +574,7 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { result.push(manhoursResult[i].manhours) projectCodeList.push(manhoursResult[i].projectNo) projectList.push(manhoursResult[i].projectName) - percentageList.push(manhoursResult[i].percentage) + percentageList.push(manhoursResult[i].manhours) } setIndividualManhoursMaxValue(maxValue) setIndividualStaffProjectList(projectList) @@ -599,7 +606,7 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { result.push(manhoursResult[i].manhours) projectCodeList.push(manhoursResult[i].projectNo) projectList.push(manhoursResult[i].projectName) - percentageList.push(manhoursResult[i].percentage) + percentageList.push(manhoursResult[i].manhours) } setIndividualManhoursMaxValue(maxValue) setIndividualStaffProjectList(projectList) @@ -756,6 +763,13 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { ]; const options: ApexOptions = { + tooltip: { + y: { + formatter: function (val) { + return val.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }); + } + } + }, chart: { height: 350, type: "line", @@ -783,6 +797,11 @@ const StaffUtilization: React.FC = ({ abilities, staff }) => { min: 0, max: totalManHoursMaxValue, tickAmount: 5, + labels: { + formatter: function (val) { + return val.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + } + } }, ], grid: {