Skip to content

Commit

Permalink
fix(point): paddingInner should always equals to 1 (close: #185) (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini committed May 12, 2022
1 parent 90336b4 commit ecd1fe3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions __tests__/unit/scales/point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ describe('point scale test', () => {
expect(scale.getBandWidth()).toStrictEqual(0);
});

test('test options.paddingInner always equals to 1', () => {
const scale = new Point({
// @ts-ignore
paddingInner: 0,
domain: ['A', 'B', 'C'],
padding: 0.6,
align: 1,
range: [0, 500],
});
expect(scale.map('A')).toStrictEqual(187.5);
expect(scale.getStep()).toStrictEqual(156.25);
expect(scale.getBandWidth()).toStrictEqual(0);
});

test('clone() returns a Point scale with same and independent options', () => {
const x1 = new Point();
const x2 = x1.clone();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/scale",
"version": "0.4.8",
"version": "0.4.9",
"description": "Toolkit for mapping abstract data into visual representation.",
"license": "MIT",
"main": "lib/index.js",
Expand Down
3 changes: 2 additions & 1 deletion src/scales/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export class Point extends Band<PointOptions & BandOptions> {
super(options);
}

// Point 的 paddingInner 只能是1,不能被覆盖
protected getPaddingInner() {
return this.options.paddingInner;
return 1;
}

public clone() {
Expand Down

0 comments on commit ecd1fe3

Please sign in to comment.