All files / datamodel/src/fields discreteMeasure.js

100% Statements 7/7
100% Branches 4/4
100% Functions 4/4
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                  11x 11x 11x                       61x 61x       4x     14x          
import Measure from './measure';
 
/**
 * Represents categorical field subtype.
 *
 * @extends Measure
 */
class DiscreteMeasure extends Measure {
    constructor(name, data, schema, bin) {
        super(name, data, schema);
        this.bin = bin;
        this.subtype = 'discrete';
    }
 
    /**
     * A hook which is called for every entry(cell) of the column.
     *
     * @todo Fix the null data e.g. undefined or null etc.
     *
     * @param {*} val - The current entry present in the column while iteration.
     * @return {string} Returns the string representation of the value.
     */
    parse (val) {
        val = (val === undefined || val === null) ? '' : val.toString();
        return val.trim();
    }
 
    bins() {
        return this.bin;
    }
    subType() {
        return this.subtype;
    }
}
 
export default DiscreteMeasure;