How to use the @antv/coord/lib/.Polar function in @antv/coord

To help you get started, we’ve selected a few @antv/coord 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 / test / unit / geom / label / polar-labels-spec.js View on Github external
describe('transpose labels', function() {
    const coord = new Coord.Polar({
      start: {
        x: 0,
        y: 100
      },
      end: {
        x: 100,
        y: 0
      }
    });
    coord.transpose();

    describe('offset < 0', function() {
      let gLabels;
      it('init', function() {
        gLabels = canvas.addGroup(PolarLabels, {
          coord,
github antvis / G2 / test / unit / geom / util / path-spec.js View on Github external
it('get coord radius', function() {
    const coord = new Coord.Polar({
      start: {
        x: 0,
        y: 0
      },
      end: {
        x: 200,
        y: 200
      }
    });
    expect(coord.radius).equal(100);
    expect(PathUtil.getPointRadius(coord, { x: 100, y: 100 })).equal(0);
    expect(PathUtil.getPointRadius(coord, { x: 100, y: 0 })).equal(100);
  });
github antvis / G2 / test / unit / geom / util / path-spec.js View on Github external
it('convertPolarPath', function() {
    const coord = new Coord.Polar({
      start: {
        x: 0,
        y: 0
      },
      end: {
        x: 200,
        y: 200
      }
    });
    const path = [[ 'M', 0, 0 ], [ 'L', 0, 1 ], [ 'L', 0.25, 1 ]];
    const toPath = PathUtil.convertPolarPath(coord, path);
    expect(toPath).eqls([[ 'M', 100, 100 ], [ 'L', 100, 0 ], [ 'A', 100, 100, 0, 0, 1, 200, 100 ]]);
  });
github antvis / G2 / test / unit / geom / util / path-spec.js View on Github external
it('get Point Angle', function() {
    const coord = new Coord.Polar({
      start: {
        x: 0,
        y: 0
      },
      end: {
        x: 200,
        y: 200
      }
    });
    expect(PathUtil.getPointAngle(coord, { x: 100, y: 100 })).equal(0);
    expect(PathUtil.getPointAngle(coord, { x: 0, y: 100 })).equal(Math.PI);
  });
github antvis / G2 / test / unit / geom / shape / edge-spec.js View on Github external
describe('edge shape test polar', function() {
    const canvas2 = canvas;
    const coord2 = new Coord.Polar({
      start: {
        x: 0,
        y: 500
      },
      end: {
        x: 500,
        y: 0
      }
    });

    it('draw shape arc polar hasWeight', function() {
      const shapeObj = Shape.getShapeFactory('edge');
      shapeObj._coord = coord2;
      const obj = {
        x: [ 0.2, 0.4, 0.6, 0.7 ],
        y: [ 0.5, 0.5, 0.5, 0.5 ]
github antvis / G2 / test / unit / geom / shape / shape-spec.js View on Github external
it('parse path in circle', function() {
    const newCoord = new Coord.Polar({
      start: {
        x: 0,
        y: 0
      },
      end: {
        x: 200,
        y: 200
      }
    });
    const testFactory = Shape.getShapeFactory('test');
    testFactory.setCoord(newCoord);
    const shape = testFactory.getShape('test');
    let path = [[ 'M', 0, 0 ], [ 'L', 0, 1 ], [ 'L', 0.5, 1 ]];
    let toPath = shape.parsePath(path);
    expect(toPath[0]).eqls([ 'M', 100, 100 ]);
    expect(toPath[1]).eqls([ 'L', 100, 0 ]);
github antvis / G2 / test / unit / geom / shape / area-spec.js View on Github external
describe('area shapes Polar', function() {
    coord = new Coord.Polar({
      start: {
        x: 0,
        y: 500
      },
      end: {
        x: 500,
        y: 0
      }
    });
    it('getShapePoints && drawShape', function() {
      const type = 'area';
      const points1 = Area.getShapePoints(type, {
        x: 0.1,
        y: 0.2,
        y0: 0,
        size: 0.5
github antvis / G2 / test / bugs / issue-730-spec.js View on Github external
it('arc direction', () => {

    const coord = new Coord.Polar({
      start: { x: 0, y: 500 },
      end: { x: 500, y: 0 },
      startAngle: 6,
      endAngle: 3,
      innerRadius: 0.3
    });
    const shapeObj = Shape.getShapeFactory('edge');
    shapeObj._coord = coord;
    const obj = {
      x: [ 0.2, 0.4, 0.6, 0.7 ],
      y: [ 0.5, 0.5, 0.5, 0.5 ]
    };
    const points = shapeObj.getShapePoints('arc', obj);
    const shape = shapeObj.drawShape('arc', {
      points,
      color: 'green',
github antvis / G2 / test / unit / geom / label / polar-labels-spec.js View on Github external
describe('polar labels', function() {
  const coord = new Coord.Polar({
    start: {
      x: 0,
      y: 100
    },
    end: {
      x: 100,
      y: 0
    }
  });

  const labelScale = Scale.cat({
    field: 'z',
    values: [ '1', '2', '3', '4' ]
  });
  const points = [
    { x: 50, y: 10, z: 0, _origin: { x: 50, y: 10, z: '1' } },
github antvis / G2 / test / unit / geom / label / pie-labels-spec.js View on Github external
describe('pie text not stack', function() {
    const coord = new Coord.Polar({
      start: {
        x: 100,
        y: 300
      },
      end: {
        x: 200,
        y: 200
      }
    });

    coord.transpose();
    const points = [];
    const values = [];
    for (let i = 1; i <= 4; i++) {
      const obj = coord.convertPoint({
        x: 0.5,