diff --git a/__tests__/unit/scales/point.spec.ts b/__tests__/unit/scales/point.spec.ts index 01a4b27..3b19b97 100644 --- a/__tests__/unit/scales/point.spec.ts +++ b/__tests__/unit/scales/point.spec.ts @@ -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(); diff --git a/package.json b/package.json index 6075ee5..80f40e6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/scales/point.ts b/src/scales/point.ts index c767598..88e00bc 100644 --- a/src/scales/point.ts +++ b/src/scales/point.ts @@ -40,8 +40,9 @@ export class Point extends Band { super(options); } + // Point 的 paddingInner 只能是1,不能被覆盖 protected getPaddingInner() { - return this.options.paddingInner; + return 1; } public clone() {