How to use the @antv/util.isString 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 / G2Plot / src / plots / pie / component / label / spider-label.ts View on Github external
_data: d,
        x: inflectionPoint.x,
        y: inflectionPoint.y,
        r: radius + INFLECTION_OFFSET,
        fill: color,
        textGroup: null,
        _side: null,
      };
      // 创建label文本
      let texts = [];
      _.each(this.fields, (f) => {
        texts.push(d[f]);
      });
      if (this.formatter) {
        let formatted: any = this.formatter(d[angleField], { _origin: d, color }, idx);
        if (_.isString(formatted)) {
          formatted = [formatted];
        }
        texts = formatted;
      }
      const textGroup = new Group();
      const textAttrs: IAttrs = {
        x: 0,
        y: 0,
        fontSize: this.config.text.fontSize,
        lineHeight: this.config.text.fontSize,
        fontWeight: this.config.text.fontWeight,
        fill: this.config.text.fill,
      };
      // label1:下部label
      let lowerText = d[angleField];
      if (this.formatter) {
github antvis / data-set / src / transform / aggregate.ts View on Github external
function transform(dataView: View, options: Options): void {
  options = assign({} as Options, DEFAULT_OPTIONS, options);
  const fields = getFields(options);
  if (!isArray(fields)) {
    throw new TypeError('Invalid fields: it must be an array with one or more strings!');
  }
  let outputNames = options.as || [];
  if (isString(outputNames)) {
    outputNames = [outputNames];
  }
  let operations: any[] = options.operations;
  if (isString(operations)) {
    operations = [operations];
  }
  const DEFAULT_OPERATIONS = [DEFAULT_OPERATION];
  if (!isArray(operations) || !operations.length) {
    console.warn('operations is not defined, will use [ "count" ] directly.');
    operations = DEFAULT_OPERATIONS;
    outputNames = operations;
  }
  if (!(operations.length === 1 && operations[0] === DEFAULT_OPERATION)) {
    if (operations.length !== fields.length) {
      throw new TypeError("Invalid operations: it's length must be the same as fields!");
    }
    if (outputNames.length !== fields.length) {
      throw new TypeError("Invalid as: it's length must be the same as fields!");
    }
  }
github antvis / G2Plot / src / geoms / interval / main.ts View on Github external
public parseColor() {
    const props = this.plot.options;
    const colorField = this._getColorMappingField(props);
    const config: DataPointType = {};
    if (colorField) {
      config.fields = colorField;
    }
    if (props.color) {
      if (_.isString(props.color)) {
        config.values = [props.color];
      } else if (_.isFunction(props.color)) {
        config.callback = props.color;
      } else if (_.isArray(props.color)) {
        config.values = props.color;
      } else if (_.isObject(props.color)) {
        config.fields = colorField;
        config.callback = (d) => {
          return props.color[d];
        };
      }
    }
    this.config.color = config;
  }
github antvis / G2Plot / src / geoms / line / main.ts View on Github external
public parseColor() {
    const props = this.plot.initialProps;
    const config: DataPointType = {};
    if (props.seriesField) {
      config.fields = [props.seriesField];
    }
    if (_.has(props, 'color')) {
      const color = props.color;
      if (_.isString(color)) {
        config.values = [color];
      } else if (_.isFunction(color)) {
        config.callback = color;
      } else {
        config.values = color as [];
      }
    }

    this.config.color = config;
  }
github antvis / G2Plot / src / geoms / area / main.ts View on Github external
public parseColor() {
    const props = this.plot.options;
    const config: DataPointType = {};
    const colorMappingField = this._getColorMappingField();
    if (colorMappingField) {
      config.fields = colorMappingField;
    }
    if (_.has(props, 'color')) {
      const color = props.color;
      if (_.isString(color)) {
        config.values = [color];
      } else if (_.isFunction(color)) {
        config.callback = color;
      } else {
        config.values = color as [];
      }
    }
    this.config.color = config;
  }
github antvis / G2Plot / src / plots / line / interaction / range.ts View on Github external
public _initContainer() {
    const container = this.container;
    if (!container) {
      throw new Error('Please specify the container for the Slider!');
    }
    if (_.isString(container)) {
      this.domContainer = document.getElementById(container as string);
    } else {
      this.domContainer = container as HTMLElement;
    }
  }
github antvis / G2Plot / src / plots / line / interaction / range.ts View on Github external
function parsePadding(padding: number[] | number | string) {
  let top = padding[0];
  let left = padding[1];
  let right = padding[2];
  let bottom = padding[3];

  if (_.isNumber(padding) || _.isString(padding)) {
    top = left = right = bottom = padding;
  } else if (_.isArray(padding)) {
    top = padding[0];
    right = !_.isNil(padding[1]) ? padding[1] : padding[0];
    bottom = !_.isNil(padding[2]) ? padding[2] : padding[0];
    left = !_.isNil(padding[3]) ? padding[3] : right;
  }

  return [top, right, bottom, left];
}
github antvis / data-set / src / transform / rename.ts View on Github external
forIn(map, (value, key) => {
      if (isString(value) && isString(key)) {
        cleanMap[key] = value;
      }
    });
  }
github antvis / G2 / src / geometry / geometry.ts View on Github external
public tooltip(field: TooltipOption | boolean | string, cfg?: TooltipCallback): Geometry {
    if (_.isString(field)) {
      const fields = parseFields(field);
      this.tooltipOption = {
        fields,
        callback: cfg,
      };
    } else {
      this.tooltipOption = field;
    }

    return this;
  }