How to use the @antv/util.isEmpty 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 / src / geometry / element / index.ts View on Github external
private getAnimateCfg(animateType: string) {
    const animate = this.animate;
    const { geometryType, coordinate } = this.shapeFactory;
    const defaultCfg = getDefaultAnimateCfg(geometryType, coordinate, animateType);

    // 1. animate === false, 用户关闭动画
    // 2. 动画默认开启,用户没有对动画进行配置同时有没有内置的默认动画
    // 3. 用户关闭对应的动画  animate: { enter: false }
    if (
      !animate ||
      (animate === true && isEmpty(defaultCfg)) ||
      animate[animateType] === false ||
      animate[animateType] === null
    ) {
      return null;
    }

    return {
      ...defaultCfg,
      ...animate[animateType],
    };
  }
github antvis / G2 / src / geometry / geometry.ts View on Github external
public getDefaultValue(attrName: string) {
    let value: any;
    const attr = this.getAttribute(attrName);
    if (attr && _.isEmpty(attr.scales)) {
      // 获取映射至常量的值
      value = attr.values[0];
    }
    return value;
  }
github antvis / G2 / packages / g2 / src / plot / controller / legend.ts View on Github external
private filterLabels(shape, element: Element, visible: boolean) {
    if (shape.get('gLabel')) {
      // shape 中缓存了 gLabel Shape
      shape.get('gLabel').set('visible', visible);
    } else {
      /* 从 label 中获取 shape 对应的 label item */
      const labelOptions = element.get('labelOptions');
      if (!_.isEmpty(_.get(labelOptions, 'fields'))) {
        const { field: xField } = element.getXScale();
        const { field: yField } = element.getYScale();
        const shapeData = shape.get('origin')._origin;
        const labels = element.get('labels') as Label[];
        _.each(labels, (label) => {
          const labelData = label.get('origin') || [];
          if (labelData[xField] === shapeData[xField] && labelData[yField] === shapeData[yField]) {
            label.set('visible', visible);
            shape.set('gLabel', label);
          }
        });
      }
    }
  }
github antvis / G2 / packages / g2 / src / plot / controller / axis.ts View on Github external
public createAxis(xScale: Scale, yScales: Scale[], viewId) {
    const coord = this.coord;
    const coordType = coord.type;

    // theta坐标系默认不绘制坐标轴
    if (coordType !== 'theta' && !(coordType === 'polar' && coord.isTransposed)) {
      let xAxis;
      if (xScale && !this._isHide(xScale.field)) {
        xAxis = this._drawAxis(coord, xScale, yScales[0], 'x', viewId); // 绘制 x 轴
      }
      if (!_.isEmpty(yScales) && coordType !== 'helix') {
        _.each(yScales, (yScale, index) => {
          if (!this._isHide(yScale.field)) {
            this._drawAxis(coord, yScale, xScale, 'y', viewId, xAxis, index);
          }
        });
      }
    }
  }
github antvis / G2 / packages / g2 / src / animate / action.ts View on Github external
function getPointsBox(points: PointObject[]) {
  if (_.isEmpty(points)) {
    return null;
  }

  let minX = points[0].x;
  let maxX = points[0].x;
  let minY = points[0].y;
  let maxY = points[0].y;
  _.each(points, (point) => {
    minX = minX > point.x ? point.x : minX;
    maxX = maxX < point.x ? point.x : maxX;
    minY = minY > point.y ? point.y : minY;
    maxY = maxY < point.y ? point.y : maxY;
  });
  return {
    minX,
    maxX,
github antvis / G2 / src / util / graphics.ts View on Github external
function getPointsBox(points) {
  if (isEmpty(points)) {
    return null;
  }

  let minX = points[0].x;
  let maxX = points[0].x;
  let minY = points[0].y;
  let maxY = points[0].y;
  each(points, (point) => {
    minX = minX > point.x ? point.x : minX;
    maxX = maxX < point.x ? point.x : maxX;
    minY = minY > point.y ? point.y : minY;
    maxY = maxY < point.y ? point.y : maxY;
  });

  return {
    minX,
github antvis / G2Plot / src / sparkline / ring-progress / animation / index.ts View on Github external
function getPointsBox(points: any[]) {
  if (_.isEmpty(points)) {
    return null;
  }

  let minX = points[0].x;
  let maxX = points[0].x;
  let minY = points[0].y;
  let maxY = points[0].y;
  _.each(points, (point) => {
    minX = minX > point.x ? point.x : minX;
    maxX = maxX < point.x ? point.x : maxX;
    minY = minY > point.y ? point.y : minY;
    maxY = maxY < point.y ? point.y : maxY;
  });
  return {
    minX,
    maxX,