lib/providers/metrics-provider.js
function getAveragedAggregate(rows, startIndex, endIndex) {
        var averagedAggregate = getInitializedAverage(metricData);

        // this is the number of elements we will aggregate
        var aggregateCount = endIndex - startIndex + 1;

        // you can compute an average of a set of numbers two ways
        // first, you can add all the numbers together and then divide by the count
        // second, you call divide each number by the count and add the quotients
        // the first method is more accurate, however you can overflow an accumulator
        // and result with NaN
        // the second method is employed here to ensure no overflows

        for (var dataKey in metricData) {
          for (var dataMetricKey in metricData[dataKey]) {
            for (var rowIndex = startIndex; rowIndex <= endIndex; rowIndex++) {
              averagedAggregate[dataKey][dataMetricKey] +=
                rows[rowIndex][dataKey][dataMetricKey] / aggregateCount;
            }

            // after the average is done, truncate the averages to one decimal point
            averagedAggregate[dataKey][dataMetricKey] =
              +averagedAggregate[dataKey][dataMetricKey].toFixed(1);
          }
        }

        return averagedAggregate;
      }
function getAveragedAggregate(rows, startIndex, endIndex) {
        var averagedAggregate = getInitializedAverage(metricData);

        // this is the number of elements we will aggregate
        var aggregateCount = endIndex - startIndex + 1;

        // you can compute an average of a set of numbers two ways
        // first, you can add all the numbers together and then divide by the count
        // second, you call divide each number by the count and add the quotients
        // the first method is more accurate, however you can overflow an accumulator
        // and result with NaN
        // the second method is employed here to ensure no overflows

        for (var dataKey in metricData) {
          for (var dataMetricKey in metricData[dataKey]) {
            for (var rowIndex = startIndex; rowIndex <= endIndex; rowIndex++) {
              averagedAggregate[dataKey][dataMetricKey] +=
                rows[rowIndex][dataKey][dataMetricKey] / aggregateCount;
            }

            // after the average is done, truncate the averages to one decimal point
            averagedAggregate[dataKey][dataMetricKey] =
              +averagedAggregate[dataKey][dataMetricKey].toFixed(1);
          }
        }

        return averagedAggregate;
      }
function getAveragedAggregate ( rows , startIndex , endIndex ) { var averagedAggregate = getInitializedAverage ( metricData ) ; // this is the number of elements we will aggregate var aggregateCount = endIndex - startIndex + 1 ; // you can compute an average of a set of numbers two ways // first, you can add all the numbers together and then divide by the count // second, you call divide each number by the count and add the quotients // the first method is more accurate, however you can overflow an accumulator // and result with NaN // the second method is employed here to ensure no overflows for ( var dataKey in metricData ) { for ( var dataMetricKey in metricData [ dataKey ] ) { for ( var rowIndex = startIndex ; rowIndex <= endIndex ; rowIndex ++ ) { averagedAggregate [ dataKey ] [ dataMetricKey ] += rows [ rowIndex ] [ dataKey ] [ dataMetricKey ] / aggregateCount ; } // after the average is done, truncate the averages to one decimal point averagedAggregate [ dataKey ] [ dataMetricKey ] = + averagedAggregate [ dataKey ] [ dataMetricKey ] . toFixed ( 1 ) ; } } return averagedAggregate ; }
After having detected a new sampling, aggregate the relevant data points

@param {Object[]} rows
The array reference.

@param {Number} startIndex
The starting index to derive an average.

@param {Number} endIndex
The ending index to derive an average.

@returns {void}
After having detected a new sampling aggregate the relevant data points