/** Documentation: * Function is used to calculate normalized pvPotential data * it normalizes every value from the array */ var minAndMaxPvPotentials = []; //getting the min and max for each attributes function setMinAndMax(pvPotentialValue) { let pvPotentials = []; pvPotentialSurfaces.forEach(t => { for (const [key, value] of Object.entries(t.attributes.pvPotential)) { if (key === pvPotentialValue) { pvPotentials.push(value); } } }); pvPotentials = pvPotentials.sort(function(a, b) { return a - b; }); minAndMaxPvPotentials = []; minAndMaxPvPotentials.push(pvPotentials[0]); minAndMaxPvPotentials.push(pvPotentials[pvPotentials.length - 1]); console.log("setMinAndMax calculated"); } //calculating the normalized value for the selected pvPotential value function getNormalizedValue(selectedPvPotentialValue) { var normalizedValue; if (minAndMaxPvPotentials[1] - minAndMaxPvPotentials[0] !== 0) { normalizedValue = (selectedPvPotentialValue - minAndMaxPvPotentials[0]) / (minAndMaxPvPotentials[1] - minAndMaxPvPotentials[0]); } else { normalizedValue = 1; } return normalizedValue; }