How to use the @antv/util.assign 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 / annotation / arc.ts View on Github external
// 即等于求 start -> center 和 end -> center 的逆时针角度
      const dAngle = vec2.angleTo(
        [ coordCenter.x - start.x, coordCenter.y - start.y ],
        [ coordCenter.x - end.x, coordCenter.y - end.y ],
        0,
      );
      const largeArc = dAngle > Math.PI ? 1 : 0;
      path = [
        [ 'M', start.x, start.y ],
        [ 'A', radius, radius, 0, largeArc, 1, end.x, end.y ],
      ];
    }

    const arcShape = group.addShape('path', {
      zIndex: this.get('zIndex'),
      attrs: _.assign({ path }, this.get('style')),
    });
    arcShape.name = 'annotation-arc'; // 用于事件以及动画识别

    if (this.get('appendInfo')) {
      arcShape.setSilent('appendInfo', this.get('appendInfo'));
    }

    this.set('el', arcShape);
  }
}
github antvis / data-set / src / transform / tag-cloud.ts View on Github external
function transform(dataView: View, options: Options): void {
  options = assign({} as Options, DEFAULT_OPTIONS, options);
  const layout = tagCloud();
  ['font', 'fontSize', 'padding', 'rotate', 'size', 'spiral', 'timeInterval'].forEach((key) => {
    // @ts-ignore
    if (options[key]) {
      // @ts-ignore
      layout[key](options[key]);
    }
  });
  const fields = getFields(options);
  const [text, value] = fields;
  if (!isString(text) || !isString(value)) {
    throw new TypeError('Invalid fields: must be an array with 2 strings (e.g. [ "text", "value" ])!');
  }
  const words = dataView.rows.map((row) => {
    row.text = row[text];
    row.value = row[value];
github antvis / data-set / src / transform / geo / region.ts View on Github external
function transform(view: View, options: Options): void {
  options = assign({} as Options, DEFAULT_OPTIONS, options);
  const field = getField(options);
  // @ts-ignore
  let geoView = options.geoView || options.geoDataView; // alias
  if (isString(geoView)) {
    geoView = view.dataSet.getView(geoView);
  }
  if (!geoView || geoView.dataType !== 'geo') {
    throw new TypeError('Invalid geoView: must be a DataView of GEO dataType!');
  }
  const as = options.as;
  if (!isArray(as) || as.length !== 2) {
    throw new TypeError('Invalid as: it must be an array with 2 strings (e.g. [ "x", "y" ])!');
  }
  const lonField = as[0];
  const latField = as[1];
  view.rows.forEach((row) => {
github antvis / G2Plot / src / components / description.ts View on Github external
constructor(cfg: TextConfig) {
    _.assign(this as any, cfg);
    this._init();
  }
github antvis / G2Plot / src / geoms / base.ts View on Github external
constructor(cfg) {
    _.assign(this, cfg);
    this.init();
  }
github antvis / data-set / src / transform / regression.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) || fields.length !== 2) {
    throw new TypeError('invalid fields: must be an array of 2 strings.');
  }
  const [xField, yField] = fields;
  const method = options.method;
  if (REGRESSION_METHODS.indexOf(method) === -1) {
    throw new TypeError(`invalid method: ${method}. Must be one of ${REGRESSION_METHODS.join(', ')}`);
  }
  const points: any[] = dataView.rows.map((row) => [row[xField], row[yField]]);
  const regressionResult = regression[method](points, options);
  let extent = options.extent;
  if (!isArray(extent) || extent.length !== 2) {
    extent = dataView.range(xField);
  }
  let bandwidth = options.bandwidth;
github antvis / G2Plot / src / tiny-plots / progress / event.ts View on Github external
import * as _ from '@antv/util';
import { EVENT_MAP, IEventmap, onEvent } from '../../util/event';

const SHAPE_EVENT_MAP: IEventmap = {
  onProgressClick: 'interval:click',
  onProgressDblclick: 'interval:dblclick',
  onProgressMousemove: 'interval:mousemove',
  onProgressMousedown: 'interval:mousedown',
  onProgressMouseup: 'interval:mouseup',
  onProgressMouseenter: 'interval:mouseenter',
  onProgressMouseleave: 'interval:mouseleave',
  onProgressContextmenu: 'interval:contextmenu',
};

_.assign(EVENT_MAP, SHAPE_EVENT_MAP);

export { EVENT_MAP, onEvent };
github antvis / G2Plot / src / sparkline / tiny-column / event.ts View on Github external
import * as _ from '@antv/util';
import { EVENT_MAP, IEventmap, onEvent } from '../../util/event';

const SHAPE_EVENT_MAP: IEventmap = {
  onColumnClick: 'interval:click',
  onColumnDblclick: 'interval:dblclick',
  onColumnMousemove: 'interval:mousemove',
  onColumnMousedown: 'interval:mousedown',
  onColumnMouseup: 'interval:mouseup',
  onColumnMouseenter: 'interval:mouseenter',
  onColumnMouseleave: 'interval:mouseleave',
  onColumnContextmenu: 'interval:contextmenu',
};

_.assign(EVENT_MAP, SHAPE_EVENT_MAP);

export { EVENT_MAP, onEvent };
github antvis / G2Plot / src / util / responsive / responsive.ts View on Github external
constructor(cfg: ResponsiveCfg) {
    _.assign(this, cfg);
    this.currentConstraint = this.constraints[0];
    if (this.rules) {
      this.iterationTime = this.rules[this.currentConstraint.name].length;
    }
    this._start();
    this._run();
    this._end();
  }
github antvis / data-set / src / transform / kernel-smooth / density.ts View on Github external
function transform(dv: View, options: Options): void {
  options = assign({} as Options, DEFAULT_OPTIONS, options);
  const fields = getFields(options);
  if (!isArray(fields) || fields.length !== 2) {
    throw new TypeError('invalid fields: must be an array of 2 strings!');
  }
  const [asX, asY, asZ] = options.as;
  if (!isString(asX) || !isString(asY) || !isString(asZ)) {
    throw new TypeError('invalid as: must be an array of 3 strings!');
  }
  let method: Function;
  if (isString(options.method)) {
    if (KERNEL_METHODS.indexOf(options.method) === -1) {
      throw new TypeError(`invalid method: ${options.method}. Must be one of ${KERNEL_METHODS.join(', ')}`);
    }
    method = kernel[options.method];
  }