diff --git a/public/js/src_modules/chartScatterPlot.mjs b/public/js/src_modules/chartScatterPlot.mjs index ff1119286cccfed9f693f533bc7c13543303b6a4..71a32d98c0c37006ef8d2dfc58bb2414e2d9886c 100644 --- a/public/js/src_modules/chartScatterPlot.mjs +++ b/public/js/src_modules/chartScatterPlot.mjs @@ -36,20 +36,18 @@ const formatSensorThingsApiResponseForScatterPlot = function ( obsArrayOne, obsArrayTwo ) { - // When our observation arrays have DIFFERENT lengths - if (obsArrayOne.length !== obsArrayTwo.length) { - const [obsArrayOneFinal, obsArrayTwoFinal] = - checkForAndDeleteUniqueObservationsFromLargerArray( - obsArrayOne, - obsArrayTwo - ); - - return createCombinedObservationValues(obsArrayOneFinal, obsArrayTwoFinal); - } - // When our observation arrays already have SAME lengths - else { - return createCombinedObservationValues(obsArrayOne, obsArrayTwo); - } + // Check if our observation arrays have equal lengths, + // remove the unique observations, if necessary + const [obsArrayOneFinal, obsArrayTwoFinal] = + obsArrayOne.length !== obsArrayTwo.length + ? checkForAndDeleteUniqueObservationsFromLargerArray( + obsArrayOne, + obsArrayTwo + ) + : [obsArrayOne, obsArrayTwo]; + + // Create the combined observations array + return createCombinedObservationValues(obsArrayOneFinal, obsArrayTwoFinal); }; /**