From ecd1fe3d696c45afed0e1e327f29936c8f754880 Mon Sep 17 00:00:00 2001 From: MiniPear Date: Thu, 12 May 2022 11:33:37 +0800 Subject: [PATCH] fix(point): paddingInner should always equals to 1 (close: #185) (#186) --- __tests__/unit/scales/point.spec.ts | 14 ++++++++++++++ package.json | 2 +- src/scales/point.ts | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/__tests__/unit/scales/point.spec.ts b/__tests__/unit/scales/point.spec.ts index 01a4b273..3b19b97c 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 6075ee55..80f40e68 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 c7675984..88e00bc0 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() {