filter/filter-log.js

/**
 * Copyright (c) 2019
 *
 * @summary chart class
 * @author Elitza Vasileva
 * @author Bernhard Pointner
 */
class FilterLog {
    constructor(_dimensions,_cat_identifier, _cat_identifier_start, _column) {
        this.dimensions = _dimensions; // crossfilter dimensions list
        this.cat_identifier = _cat_identifier;
        this.cat_identifier_start = _cat_identifier_start;
        this.start = null;
        this.end = null;
        this.column = _column;
    }

    /**
     * Updates the brushing filter by setting a new start and end value
     * @param start   start value
     * @param end   end value
     */
    updateFilter(start,end) {
        this.start = start;
        this.end = end;
    }

    /**
     * Evaluates the row according to the start and end
     * @param row   the row to be evaluated
     * @param i
     * @returns {boolean}
     */
    evaluateRow(row,i) {
        if(this.start != null) {
            let value = Math.ceil(row[this.column]/Math.pow(10,(''+row[this.column]).length))*Math.pow(10,(''+row[this.column]).length-1);
            return value >= this.start && value <= this.end;
        } else {
            return true;
        }
    }

    /**
     * resets the filter
     */
    resetFilter() {
        this.start = null;
        this.end = null;
    }
}