How to use the @antv/util.isNumber function in @antv/util

To help you get started, we’ve selected a few @antv/util 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 antvis / G2 / packages / component / src / axis / line.ts View on Github external
public getSideVector(offset) {
    const isVertical = this.get('isVertical');
    const factor = this.get('factor');
    // if (Util.isArray(offset)) {
    //   return offset.map(value => value * factor);
    // }
    if (!Util.isNumber(offset)) {
      return [0, 0];
    }
    const start = this.get('start');
    const end = this.get('end');
    const axisVector = this.getAxisVector();
    const normal = vec2.normalize([], axisVector);
    let direction = false;
    if ((isVertical && start.y < end.y) || (!isVertical && start.x > end.x)) {
      direction = true;
    }
    const verticalVector = vec2.vertical([], normal, direction);
    return vec2.scale([], verticalVector, offset * factor);
  }
github antvis / G2Plot / src / plots / line / interaction / range.ts View on Github external
public _initRange() {
    const startRadio = this.startRatio;
    const endRadio = this.endRatio;
    const start = this._startValue;
    const end = this._endValue;
    const scale = this.scale;
    let min = 0;
    let max = 1;

    // startRadio 优先级高于 start
    if (_.isNumber(startRadio)) {
      min = startRadio;
    } else if (start) {
      min = scale.scale(scale.translate(start));
    }

    // endRadio 优先级高于 end
    if (_.isNumber(endRadio)) {
      max = endRadio;
    } else if (end) {
      max = scale.scale(scale.translate(end));
    }
    const { minSpan, maxSpan } = this;
    let totalSpan = 0;
    if (scale.type === 'time' || scale.type === 'timeCat') {
      // 时间类型已排序
      const values = scale.values;
github antvis / G2 / src / geometry / geometry.ts View on Github external
private _createAttrOption(attrName: string, field: AttributeOption | string | number, cfg?) {
    if (_.isObject(field)) {
      this._setAttrOptions(attrName, field);
    } else {
      const attrCfg: AttributeOption = {};
      if (_.isNumber(field)) {
        // size(3)
        attrCfg.values = [field];
      } else {
        attrCfg.fields = parseFields(field);
      }

      if (cfg) {
        if (_.isFunction(cfg)) {
          attrCfg.callback = cfg;
        } else {
          attrCfg.values = cfg;
        }
      }

      this._setAttrOptions(attrName, attrCfg);
    }
github antvis / G2Plot / src / util / responsive / rules.ts View on Github external
_.each(keepCfg, (cfg) => {
    if (cfg === 'start') {
      conditions.push(index === 0);
    } else if (cfg === 'end') {
      conditions.push(index === nodes.length - 1);
    } else if (_.isNumber(cfg)) {
      conditions.push(index === cfg);
    }
  });
  for (let i = 0; i < conditions.length; i++) {
github antvis / G2Plot / src / geoms / heatmap / linear.ts View on Github external
_prepareSize() {
    let radius;
    if (this.get('radius')) {
      radius = this.get('radius');
    } else {
      radius = this.getDefaultValue('size');
      if (!_.isNumber(radius)) {
        radius = this.getDefaultSize();
      }
    }

    const styleOptions = this.get('styleOptions');
    let blur = styleOptions && _.isObject(styleOptions.cfg) ? styleOptions.cfg.blur : null;
    if (!_.isFinite(blur) || blur === null) {
      blur = radius / 2;
    }
    this.set(HEATMAP_SIZE, {
      blur,
      radius,
    });
  }
github antvis / G2 / src / geometry / label / base.ts View on Github external
(mappingData.points as Point[]).forEach((p: Point) => {
        let p1 = p;
        p1 = coordinate.convert(p1);
        if (
          (isArray(p1.x) && (mappingData.x as number[]).indexOf(p1.x) === -1) ||
          (isNumber(p1.x) && mappingData.x !== p1.x)
        ) {
          label.x = (label.x + p1.x) / 2;
        }
      });
    }