mixins/dataProcessing.js
/**
     * Maps data values to be per-capita rather than absolute
     * Non-reported days are set to `null`, for the most part.
     * @param {number[]} arr - Array of absolute new case values
     * @param {object} popObj - Population object
     * @param {number} popObj.population - Population of province/region
     * @param {string} popObj.initials - Identifier for province/region
     * @returns {number[]}
     */
Maps data values to be per-capita rather than absolute
Non-reported days are set to `null`, for the most part.
Maps data values to be per - capita rather than absolute Non - reported days are set to ` null ` for the most part .
processDataArray(arr, popObj) {
      return arr.map((dataObj, dataIndex) => {
        let output =
          dataObj.rows[popObj.initials] / (popObj.population / this.per);
        const specialCases = ["BC", "AB", "ON", "Canada"];
        const shouldBeNull =
          dataIndex > 30 &&
          output === 0 &&
          specialCases.includes(popObj.initials);
        if (shouldBeNull) {
          output = null;
        }
        if (typeof output === "number" && output < 0) {
          output = 0;
        }
        return output;
      });
    }
processDataArray ( arr , popObj ) { return arr . map ( ( dataObj , dataIndex ) => { let output = dataObj . rows [ popObj . initials ] / ( popObj . population / this . per ) ; const specialCases = [ "BC" , "AB" , "ON" , "Canada" ] ; const shouldBeNull = dataIndex > 30 && output === 0 && specialCases . includes ( popObj . initials ) ; if ( shouldBeNull ) { output = null ; } if ( typeof output === "number" && output < 0 ) { output = 0 ; } return output ; } ) ; }
Maps data values to be per-capita rather than absolute
 Non-reported days are set to `null`, for the most part.
Maps data values to be per - capita rather than absolute Non - reported days are set to ` null ` for the most part .
// calculate the per-capita rate // some regions do not report on certain days. We will map those to null for now. Later we will average the next reported day over the nulls. // it is difficult to differentiate between a "real" 0 value and a day for which no numbers were released. // the following line makes a best guess. The records start with Jan 25, and the affected regions haven't had a "real" 0 day since ~ late feb (that is where the `dataIndex > 30` comes from) // I'm seeing a few -1's in SK MB and NF, which does not make sense to me. Without looking into the cause, lets just make it 0 for now