How to use the @antv/matrix-util.vec2 function in @antv/matrix-util

To help you get started, we’ve selected a few @antv/matrix-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 / g2 / src / plot / controller / tooltip.ts View on Github external
import { Tooltip } from '@antv/component';
import * as matrixUtil from '@antv/matrix-util';
import * as _ from '@antv/util';
import Element from '../../element/base';
import { getShapeFactory } from '../../element/shape/base';
import { DataPointType } from '../../interface';
import View from '../view';
const Vector2 = matrixUtil.vec2;

const TYPE_SHOW_MARKERS = ['line', 'area', 'path']; // 默认展示 tooltip marker 的几何图形
const TYPE_SHOW_CROSSHAIRS = ['line', 'area']; // 默认展示十字瞄准线的几何图形

// TODO FIXME this is HARD CODING
const IGNORE_TOOLTIP_ITEM_PROPERTIES = ['marker', 'showMarker'];

const _indexOfArray = (items, item) => {
  let rst = -1;
  _.each(items, (sub, index: number) => {
    let isEqual = true;
    for (const key in item) {
      if (item.hasOwnProperty(key) && IGNORE_TOOLTIP_ITEM_PROPERTIES.indexOf(key) === -1) {
        if (!_.isObject(item[key]) && item[key] !== sub[key]) {
          isEqual = false;
          break;
github antvis / G2Plot / src / util / path.ts View on Github external
/**
 * @description path 计算、转换的辅助工具
 */

import * as matrixUtil from '@antv/matrix-util';
import * as _ from '@antv/util';
const vector2 = matrixUtil.vec2;

interface PointObject {
  x: number;
  y: number;
}

type PointArray = [number, number];

function _points2path(points: PointObject[], isInCircle: boolean): any[] {
  const path = [];
  if (points.length) {
    for (let i = 0, length = points.length; i < length; i += 1) {
      const item = points[i];
      const command = i === 0 ? 'M' : 'L';
      path.push([command, item.x, item.y]);
    }