From 9a25f8646b1f5e7c6c718e113ef0e0122cfa7e22 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 4 Jul 2023 16:45:52 +0700 Subject: [PATCH] Fix s curve --- view-mode/function/overlaySCurve.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/view-mode/function/overlaySCurve.js b/view-mode/function/overlaySCurve.js index 04bb204..364d90e 100644 --- a/view-mode/function/overlaySCurve.js +++ b/view-mode/function/overlaySCurve.js @@ -34,13 +34,22 @@ function getSCurveData(){ "Content-Type": "application/json", "Authorization": `Bearer ${token}` }, - url: `${base_url}project/get-linear-s-curve`, + url: `${base_url}project/calculate-s-curve`, type: "POST", data:JSON.stringify(sCurvePayload), success: function (data) { callback(data) } }); + $.ajax({ + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + }, + url: `${base_url}project/s-curve-command`, + type: "POST", + data:JSON.stringify(sCurvePayload), + }); } else { $.ajax({ headers: { @@ -93,7 +102,19 @@ function getProgressLine(){ getSCurveData(); var cumulativePlannedDurations = return_first.data[0].data.percentagePlan; var cumulativeRealDurations = return_first.data[0].data.percentageReal; + var maxPlan = cumulativePlannedDurations[cumulativePlannedDurations.length - 1] + var maxReal = cumulativeRealDurations[cumulativeRealDurations.length - 1] var dates = return_first.data[0].data.date; + if (maxReal > 100 || maxPlan > 100) { + var plannedDurations = cumulativePlannedDurations.map((item) => { + return item/maxPlan*100; + }) + var realDurations = cumulativeRealDurations.map((item) => { + return item/maxPlan*100; + }) + return {planned: plannedDurations, real: realDurations, dates: dates}; + } + return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates}; }