From a9db75afb6aaefb60d9d36b8365e091fded72bd4 Mon Sep 17 00:00:00 2001 From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de> Date: Tue, 14 Sep 2021 16:38:44 +0200 Subject: [PATCH] New function: get index of missing observations Currently, this function is only available in the scope of the function that formats observations for the scatter plot chart. Get the index of the observations that are available in the first array but are missing from the second array. --- public/js/appChart.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/js/appChart.js b/public/js/appChart.js index be10d07..af98551 100644 --- a/public/js/appChart.js +++ b/public/js/appChart.js @@ -846,6 +846,29 @@ const formatSTAResponseForScatterPlot = function (obsArrayOne, obsArrayTwo) { obsArrayTwoTimestamp ); console.log(missingTimestamp); + + /** + * + * @param {Array} missingTimestampsArr An array of strings representing the missing timestamps + * @param {Array} firstObsTimestampArr An array of timestamps for the first set of observations + * @returns {Array} An array of the indexes of the missing observations + */ + const getIndexOfMissingObservation = function ( + missingTimestampsArr, + firstObsTimestampArr + ) { + const indexesMissingObs = missingTimestampsArr.map((index) => + firstObsTimestampArr.indexOf(index) + ); + + // console.log(indexes); + return indexesMissingObs; + }; + + const indexesMissingObsArr = getIndexOfMissingObservation( + missingTimestamp, + obsArrayOneTimestamp + ); }; (async () => { -- GitLab