From a2cbd098976938ab86b56896b3e049a06cd745af Mon Sep 17 00:00:00 2001 From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de> Date: Tue, 14 Sep 2021 16:40:00 +0200 Subject: [PATCH] New function: remove missing observations Currently, this function is only available in the scope of the function that formats observations for the scatter plot chart. Remove the missing observations from the first (larger) array. --- public/js/appChart.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/js/appChart.js b/public/js/appChart.js index af98551..2c925e9 100644 --- a/public/js/appChart.js +++ b/public/js/appChart.js @@ -869,6 +869,29 @@ const formatSTAResponseForScatterPlot = function (obsArrayOne, obsArrayTwo) { missingTimestamp, obsArrayOneTimestamp ); + + /** + * + * @param {*} missingIndexesArr An array of the indexes of the observations missing from the second set of observations + * @param {*} obsOneArr An array of the first set of observations (timestamp + value) + * @returns {undefined} + */ + const removeMissingObservationFromFirstArray = function ( + missingIndexesArr, + obsOneArr + ) { + missingIndexesArr.forEach((index) => { + if (index > -1) { + obsOneArr.splice(index, 1); + } + }); + }; + + removeMissingObservationFromFirstArray( + indexesMissingObsArr, + obsArrayOneChecked + ); + console.log(obsArrayOneChecked.length); }; (async () => { -- GitLab