From c1bb5021958112fb91ad71f395e023fa8518cf05 Mon Sep 17 00:00:00 2001 From: linlang <2550244256@qq.com> Date: Sun, 10 Nov 2024 20:29:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=20NaN=E4=B8=8D=E5=BA=94=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=9C=89=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit debug 20265 --- src/scale/helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scale/helper.ts b/src/scale/helper.ts index 31f41945ec..cb6d8f7d05 100644 --- a/src/scale/helper.ts +++ b/src/scale/helper.ts @@ -151,7 +151,7 @@ function normalize( // Dont use optional arguments for performance consideration here. ): number { if (extent[1] === extent[0]) { - return 0.5; + return isNaN(val) ? NaN : 0.5; } return (val - extent[0]) / (extent[1] - extent[0]); } From 7cadad5620778d6284e14640de7f270ac5406eda Mon Sep 17 00:00:00 2001 From: linlang177 <2550244256@qq.com> Date: Tue, 2 Sep 2025 20:21:24 +0800 Subject: [PATCH 2/3] add test --- test/line-scale.html | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/line-scale.html diff --git a/test/line-scale.html b/test/line-scale.html new file mode 100644 index 0000000000..229922b57b --- /dev/null +++ b/test/line-scale.html @@ -0,0 +1,61 @@ + + + + + + Line Scale Test + + + + + + +
+ + + + From c12d52a1841b4f4d8ec3ecf2818487b48ac05238 Mon Sep 17 00:00:00 2001 From: linlang177 <2550244256@qq.com> Date: Sun, 19 Apr 2026 18:50:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat=20=E5=A4=84=E7=90=86filtermode?= =?UTF-8?q?=E4=B8=BAnone=E5=8F=8A6.0=E6=96=B0=E5=A2=9E=E6=96=AD=E8=BD=B4?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/Axis.ts | 3 + src/scale/breakImpl.ts | 9 ++- src/scale/helper.ts | 8 ++- test/dataZoom-filterMode-scale.html | 102 ++++++++++++++++++++++++++++ test/line-scale.html | 61 ----------------- 5 files changed, 120 insertions(+), 63 deletions(-) create mode 100644 test/dataZoom-filterMode-scale.html delete mode 100644 test/line-scale.html diff --git a/src/coord/Axis.ts b/src/coord/Axis.ts index 6226e96b26..e54086ddd4 100644 --- a/src/coord/Axis.ts +++ b/src/coord/Axis.ts @@ -295,6 +295,9 @@ class Axis { } function fixExtentWithBands(extent: [number, number], nTick: number): void { + if (nTick <= 1) { + return; + } const size = extent[1] - extent[0]; const len = nTick; const margin = size / len / 2; diff --git a/src/scale/breakImpl.ts b/src/scale/breakImpl.ts index 67d2eaa657..b3fcadaadd 100644 --- a/src/scale/breakImpl.ts +++ b/src/scale/breakImpl.ts @@ -99,7 +99,14 @@ class ScaleBreakContextImpl implements ScaleBreakContext { const elapsedSpan = this._elapsedExtent[1] - this._elapsedExtent[0]; // The same logic as `Scale#normalize`. if (elapsedSpan === 0) { - return 0.5; + const elapsedVal = this.elapse(val); + if (isNaN(elapsedVal)) { + return NaN; + } + if (elapsedVal === this._elapsedExtent[0]) { + return 0.5; + } + return elapsedVal < this._elapsedExtent[0] ? -0.5 : 1.5; } return (this.elapse(val) - this._elapsedExtent[0]) / elapsedSpan; } diff --git a/src/scale/helper.ts b/src/scale/helper.ts index cb6d8f7d05..3ef8424bfa 100644 --- a/src/scale/helper.ts +++ b/src/scale/helper.ts @@ -151,7 +151,13 @@ function normalize( // Dont use optional arguments for performance consideration here. ): number { if (extent[1] === extent[0]) { - return isNaN(val) ? NaN : 0.5; + if (isNaN(val)) { + return NaN; + } + if (val === extent[0]) { + return 0.5; + } + return val < extent[0] ? -0.5 : 1.5; } return (val - extent[0]) / (extent[1] - extent[0]); } diff --git a/test/dataZoom-filterMode-scale.html b/test/dataZoom-filterMode-scale.html new file mode 100644 index 0000000000..e520bdceef --- /dev/null +++ b/test/dataZoom-filterMode-scale.html @@ -0,0 +1,102 @@ + + + + + DataZoom FilterMode Scale Test + + + + + + +
+
+
+
+
+
+ + + + diff --git a/test/line-scale.html b/test/line-scale.html deleted file mode 100644 index 229922b57b..0000000000 --- a/test/line-scale.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - Line Scale Test - - - - - - -
- - - -