Skip to content

Commit

Permalink
fix: parsePadding 不需要计算两次
Browse files Browse the repository at this point in the history
  • Loading branch information
Leannechn committed May 28, 2020
1 parent 8410350 commit d913722
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/chart/layout/padding-cal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PaddingCal {
* 四周增加 padding
* @param padding
*/
public shrink(padding: number[]): PaddingCal {
public shrink(padding: Padding): PaddingCal {
const [top, right, bottom, left] = padding;

this.top += top;
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ export type Renderer = 'svg' | 'canvas';
export type Datum = Record<string, any>;
export type Data = Datum[];
export type ActionCallback = (context: IInteractionContext) => void;
export type Padding = number[];
export type Padding = [number, number, number, number];
export type ViewPadding = number | number[] | 'auto';
export type ViewAppendPadding = number | number[];
export type Position = [number, number];
Expand Down
4 changes: 2 additions & 2 deletions src/util/bbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class BBox {
* @param gap
*/
public shrink(gap: Padding): BBox {
const [top, right, bottom, left] = parsePadding(gap);
const [top, right, bottom, left] = gap;

return new BBox(this.x + left, this.y + top, this.width - left - right, this.height - top - bottom);
}
Expand All @@ -185,7 +185,7 @@ export class BBox {
* @param bbox
* @returns [top, right, bottom, left]
*/
public exceed(bbox: BBox): number[] {
public exceed(bbox: BBox): Padding {
return [
Math.max(-this.minY + bbox.minY, 0),
Math.max(this.maxX - bbox.maxX, 0),
Expand Down

0 comments on commit d913722

Please sign in to comment.