lib/providers/metrics-provider.js
function MetricsProvider(screen) {

    /**
     * Setup the process to aggregate the data as and when it is necessary.
     *
     * @returns {void}
     */
    var setupAggregation =
      function setupAggregation() {
        // construct the aggregation container
        this._aggregation = _.reduce(AGGREGATE_TIME_LEVELS, function (prev, timeLevel) {
          prev[timeLevel] = {
            data: [],
            lastTimeIndex: undefined,
            lastAggregateIndex: 0,
            scrollOffset: 0
          };

          return prev;
        }, {});

        // an array of all available aggregation levels and metadata
        this.aggregationLevels = _.keys(this._aggregation);
        this.lowestAggregateTimeUnits = +this.aggregationLevels[0];
        this.highestAggregationKey = _.last(this.aggregationLevels);

        // remember when all this started
        this._startTime = Date.now();

        // this is where we stopped aggregating
        this._lastAggregationIndex = 0;
      }.bind(this);

    EventEmitter.call(this);

    // the low-level container of all metrics provided
    this._metrics = [];

    // setup for aggregation
    setupAggregation();

    // initialize the zoom level to the lowest level
    this.setZoomLevel(0);

    // callback handlers
    screen.on("metrics", this._onMetrics.bind(this));
    screen.on("zoomGraphs", this.adjustZoomLevel.bind(this));
    screen.on("scrollGraphs", this.adjustScrollOffset.bind(this));
    screen.on("startGraphs", this.startGraphs.bind(this));
    screen.on("resetGraphs", this.resetGraphs.bind(this));
  }
function MetricsProvider(screen) {

    /**
     * Setup the process to aggregate the data as and when it is necessary.
     *
     * @returns {void}
     */
    var setupAggregation =
      function setupAggregation() {
        // construct the aggregation container
        this._aggregation = _.reduce(AGGREGATE_TIME_LEVELS, function (prev, timeLevel) {
          prev[timeLevel] = {
            data: [],
            lastTimeIndex: undefined,
            lastAggregateIndex: 0,
            scrollOffset: 0
          };

          return prev;
        }, {});

        // an array of all available aggregation levels and metadata
        this.aggregationLevels = _.keys(this._aggregation);
        this.lowestAggregateTimeUnits = +this.aggregationLevels[0];
        this.highestAggregationKey = _.last(this.aggregationLevels);

        // remember when all this started
        this._startTime = Date.now();

        // this is where we stopped aggregating
        this._lastAggregationIndex = 0;
      }.bind(this);

    EventEmitter.call(this);

    // the low-level container of all metrics provided
    this._metrics = [];

    // setup for aggregation
    setupAggregation();

    // initialize the zoom level to the lowest level
    this.setZoomLevel(0);

    // callback handlers
    screen.on("metrics", this._onMetrics.bind(this));
    screen.on("zoomGraphs", this.adjustZoomLevel.bind(this));
    screen.on("scrollGraphs", this.adjustScrollOffset.bind(this));
    screen.on("startGraphs", this.startGraphs.bind(this));
    screen.on("resetGraphs", this.resetGraphs.bind(this));
  }
function MetricsProvider ( screen ) { /**
     * Setup the process to aggregate the data as and when it is necessary.
     *
     * @returns {void}
     */ var setupAggregation = function setupAggregation ( ) { // construct the aggregation container this . _aggregation = _ . reduce ( AGGREGATE_TIME_LEVELS , function ( prev , timeLevel ) { prev [ timeLevel ] = { data : [ ] , lastTimeIndex : undefined , lastAggregateIndex : 0 , scrollOffset : 0 } ; return prev ; } , { } ) ; // an array of all available aggregation levels and metadata this . aggregationLevels = _ . keys ( this . _aggregation ) ; this . lowestAggregateTimeUnits = + this . aggregationLevels [ 0 ] ; this . highestAggregationKey = _ . last ( this . aggregationLevels ) ; // remember when all this started this . _startTime = Date . now ( ) ; // this is where we stopped aggregating this . _lastAggregationIndex = 0 ; } . bind ( this ) ; EventEmitter . call ( this ) ; // the low-level container of all metrics provided this . _metrics = [ ] ; // setup for aggregation setupAggregation ( ) ; // initialize the zoom level to the lowest level this . setZoomLevel ( 0 ) ; // callback handlers screen . on ( "metrics" , this . _onMetrics . bind ( this ) ) ; screen . on ( "zoomGraphs" , this . adjustZoomLevel . bind ( this ) ) ; screen . on ( "scrollGraphs" , this . adjustScrollOffset . bind ( this ) ) ; screen . on ( "startGraphs" , this . startGraphs . bind ( this ) ) ; screen . on ( "resetGraphs" , this . resetGraphs . bind ( this ) ) ; }
This is the constructor for the MetricsProvider

@param {Object} screen
The blessed screen object.

@returns {void}
This is the constructor for the MetricsProvider