Skip to content

Commit

Permalink
fix: coordinate.rotate use Radian
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Feb 6, 2020
1 parent d223b0d commit 124f380
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/chart/controller/coordinate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,37 @@ export default class {
return this.coordinate;
}

/**
* 鏃嬭浆寮у害
* @param angle
*/
public rotate(angle: number) {
angle = angle * Math.PI / 180;
this.option.actions.push([ 'rotate', angle ]);
return this;
}

/**
* 闀滃儚
* @param dim
*/
public reflect(dim: string) {
this.option.actions.push([ 'reflect', dim ]);
return this;
}

/**
* scale
* @param sx
* @param sy
*/
public scale(sx: number, sy: number) {
this.option.actions.push([ 'scale', sx, sy ]);
return this;
}

/**
* 瀵硅鍙樻崲
*/
public transpose() {
this.option.actions.push([ 'transpose' ]);
return this;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/chart/controller/coordinate-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('test coordinate controller', () => {
expect(actions.length).toBe(1);
expect(actions[0]).toEqual([ 'transpose' ]);

controller.rotate(180);
controller.rotate(Math.PI);
expect(actions.length).toBe(2);
expect(actions[1]).toEqual([ 'rotate', Math.PI ]);

Expand All @@ -31,7 +31,7 @@ describe('test coordinate controller', () => {
expect(actions[3]).toEqual([ 'reflect', 'x' ]);
});

it('create coord', () => {
it('create coordinate', () => {
const coordinate = controller.create({ x: 0, y: 0 }, { x: 500, y: 500 });
expect(coordinate.isTransposed).toBe(true);
});
Expand Down

0 comments on commit 124f380

Please sign in to comment.