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);
});
});
it('_getRadiusCfg', function() {
const coord = new Coord.Polar({
start,
end
});
const radiusCfg = as._getRadiusCfg(coord);
expect(radiusCfg.factor).to.equal(-1);
expect(radiusCfg.start).to.eql({
x: 250,
y: 250
});
expect(radiusCfg.end).to.eql({
x: 250.00000000000003,
y: 0
});
});
it('_getRadiusCfg when coord is transpose.', function() {
const coord = new Coord.Polar({
start,
end,
startAngle: 1 / (3 * Math.PI),
endAngle: Math.PI
});
coord.transpose();
const radiusCfg = as._getRadiusCfg(coord);
expect(radiusCfg.factor).to.equal(1);
expect(radiusCfg.start).to.eql({
x: 250.70494165327872,
y: 124.94090329888789
});
expect(radiusCfg.end).to.eql({
x: 500.00000000000006,
y: 151.49164063853073
});
it('_getCircleCfg when coord is reflectY.', function() {
const coord = new Coord.Polar({
start,
end,
startAngle: 1 / (3 * Math.PI),
endAngle: Math.PI
});
coord.reflect('y');
const circleCfg = as._getCircleCfg(coord);
expect(circleCfg.startAngle).to.equal(0.10610329539459758);
expect(circleCfg.endAngle).to.equal(3.141592653589794);
expect(circleCfg.center).to.eql({
x: 250.70494165327872,
y: 124.94090329888789
});
});
it('get axis position polar', function() {
const coord = new Coord.Polar({
start,
end
});
let position = as._getAxisPosition(coord, 'x');
expect(position).to.equal('circle');
position = as._getAxisPosition(coord, 'y');
expect(position).to.equal('radius');
});
it('_getCircleCfg', function() {
const coord = new Coord.Polar({
start,
end
});
const circleCfg = as._getCircleCfg(coord);
expect(circleCfg.startAngle).to.equal(-1.5707963267948966);
expect(circleCfg.endAngle).to.equal(4.71238898038469);
expect(circleCfg.radius).to.equal(250);
expect(circleCfg.inner).to.equal(0);
expect(circleCfg.center).to.eql({ x: 250, y: 250 });
});
it('get axis position polar transpose', function() {
const coord = new Coord.Polar({
start,
end
});
coord.transpose();
let position = as._getAxisPosition(coord, 'x');
expect(position).to.equal('radius');
position = as._getAxisPosition(coord, 'y');
expect(position).to.equal('circle');
});
});
it('draw area in polar', function() {
const coord1 = new Coord.Polar({
start: {
x: 0,
y: 0
},
end: {
x: 500,
y: 500
}
});
geom.reset();
geom.set('coord', coord1);
geom.position('a*b').color('c');
geom.init();
geom.paint();
expect(shapeContainer.getCount()).equal(1);
expect(shapeContainer.getFirst().attr('path').length).equal(9);
it('锐角扇形 宽画布 反向', () => {
const width = 800;
const height = 400;
const startAngle = Math.PI * (10 / 6);
const endAngle = Math.PI * (8 / 6);
const coord = new Coord.Polar({
start: { x: 0, y: height },
end: { x: width, y: 0 },
startAngle,
endAngle
});
for (let i = startAngle; i <= endAngle; i += Math.PI / 180) {
const point = {
x: Math.cos(i) * coord.radius + coord.center.x,
y: Math.sin(i) * coord.radius + coord.center.y
};
expect(point.x >= 0 && point.x <= width).to.be.true;
expect(point.y >= 0 && point.y <= height).to.be.true;
}
expect(coord.center.y >= 0 && coord.center.y <= height).to.be.true;
expect(coord.center.x >= 0 && coord.center.x <= width).to.be.true;
});
it('_getCircleCfg when coord is transposed.', function() {
const coord = new Coord.Polar({
start,
end,
innerRadius: 0.5
});
coord.transpose();
const circleCfg = as._getCircleCfg(coord);
expect(circleCfg.startAngle).to.equal(-1.5707963267948966);
expect(circleCfg.endAngle).to.equal(4.71238898038469);
expect(circleCfg.radius).to.equal(250);
expect(circleCfg.inner).to.equal(0.5);
expect(circleCfg.center).to.eql({
x: 250,
y: 250
});
});