Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('_getAxisCfg when gridAlign is middle.', function() {
as.options = {
b: {
grid: {
align: 'center'
}
}
};
const coord = new Coord.Polar({
start,
end
});
coord.reflect('y');
const axisCfg = as._getAxisCfg(coord, scaleY, scaleX, 'y');
expect(axisCfg.ticks.length).to.equal(10);
expect(axisCfg.grid).not.to.be.empty;
expect(axisCfg.grid.type).to.equal('circle');
expect(axisCfg.grid.items.length).to.equal(12); // fixed: fill gaps
expect(axisCfg.grid.items[0]._id).not.to.be.undefined;
expect(axisCfg.grid.items[0].points.length).to.equal(12);
});
});
const expect = require('chai').expect;
const { Canvas } = require('../../../../src/renderer');
const Area = require('../../../../src/geom/shape/area');
const Coord = require('@antv/coord/lib/');
// const Global = require('../../../../src/global');
const div = document.createElement('div');
div.id = 'csarea';
document.body.appendChild(div);
let coord = new Coord.Rect({
start: {
x: 0,
y: 500
},
end: {
x: 500,
y: 0
}
});
const canvas = new Canvas({
containerId: 'csarea',
width: 500,
height: 500
});
describe('area shapes Polar', () => {
const Polar = getCoordinate('polar');
const polarCoord = new Polar({
start: {
x: 0,
y: 500,
},
end: {
x: 500,
y: 0,
},
});
it('getShapePoints && drawShape', () => {
AreaShapeFactory.setCoord(polarCoord);
const type = 'area';
const points1 = AreaShapeFactory.getShapePoints(type, {
x: 0.1,
y: 0.2,
import { getCoordinate } from '@antv/coord';
import { getScale } from '@antv/scale';
import Schema from '../../../src/geometry/schema';
import Theme from '../../../src/theme/antv';
import { createCanvas, createDiv, removeDom } from '../../util/dom';
import 'jest-extended';
import { createScale } from '../../util/scale';
const CartesianCoordinate = getCoordinate('rect');
const LinearScale = getScale('linear');
describe('Schema', () => {
const div = createDiv();
const canvas = createCanvas({
container: div,
width: 300,
height: 300,
});
const rectCoord = new CartesianCoordinate({
start: { x: 0, y: 300 },
end: { x: 300, y: 0 },
});
it('draw box', () => {
const data = [
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,
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);
});
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 ]]);
});
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);
});
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 ]
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 ]);