How to use the base/utils.isDate function in base

To help you get started, we’ve selected a few base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vizabi / vizabi / src / models / hook.js View on Github external
const filtered = items.reduce((filtered, d) => {

        // check for dates
        const f = (utils.isDate(d[attr])) ? d[attr] : parseFloat(d[attr]);

        // if it is a number
        if (!isNaN(f)) {
          filtered.push(f);
        }

        //filter
        return filtered;
      }, []);
github vizabi / vizabi / src / tools / bubblechart / bubblechart-panzoom.js View on Github external
        const formatter = function(n) { return utils.isDate(n) ? n : d3.round(n, 2); };
github vizabi / vizabi / src / models / time.js View on Github external
_formatToDates: function() {

    var date_attr = ["value", "start", "end"];
    var fmts = [this.formatInput].concat(formatters);
    for(var i = 0; i < date_attr.length; i++) {
      var attr = date_attr[i];
      if(!utils.isDate(this[attr])) {
        for(var j = 0; j < fmts.length; j++) {
          var formatter = d3.time.format(fmts[j]);
          var date = formatter.parse(this[attr].toString());
          if(utils.isDate(date)) {
            this.set(attr, date);
            break;
          }
        }
      }
    }
  },
github vizabi / vizabi / src / models / axis.js View on Github external
validate() {
    this._super();

    //restore the correct object type for time values
    if (this.scale && this.scaleType == "time") {
      const obj = {};
      if (this.zoomedMin != null && !utils.isDate(this.zoomedMin)) obj.zoomedMin = this._space.time.parse(this.zoomedMin.toString());
      if (this.zoomedMax != null && !utils.isDate(this.zoomedMax)) obj.zoomedMax = this._space.time.parse(this.zoomedMax.toString());
      this.set(obj);
    }

  },
github vizabi / vizabi / src / components / minmaxinputs / minmaxinputs.js View on Github external
const formatter = function(n) {
      if (!n && n !== 0) return n;
      if (utils.isDate(n)) return _this.model.time.formatDate(n);
      return d3.format(".2r")(n);
    };
github vizabi / vizabi / src / models / time.js View on Github external
_formatToDates() {
    const persistentValues = ["value"];
    const date_attr = ["value", "start", "end", "startSelected", "endSelected"];
    for (let i = 0; i < date_attr.length; i++) {
      const attr = date_attr[i];
      if (!utils.isDate(this[attr])) {
        const date = this.parse(this[attr]);
        this.set(attr, date, null, (persistentValues.indexOf(attr) !== -1));
      }
    }
  },
github vizabi / vizabi / src / models / time.js View on Github external
validate: function() {

    //unit has to be one of the available_time_units
    if(time_units.indexOf(this.unit) === -1) {
      this.unit = "year";
    }

    if(this.step < 1) {
      this.step = "year";
    }

    //make sure dates are transformed into dates at all times
    if(!utils.isDate(this.start) || !utils.isDate(this.end) || !utils.isDate(this.value)) {
      this._formatToDates();
    }

    //end has to be >= than start
    if(this.end < this.start) {
      this.end = this.start;
    }
    //value has to be between start and end
    if(this.value < this.start) {
      this.value = this.start;
    } else if(this.value > this.end) {
      this.value = this.end;
    }

    if(this.playable === false && this.playing === true) {
      this.playing = false;