From 69232edc2c5af146c86df56834dc7b4fc0c0e3ae Mon Sep 17 00:00:00 2001 From: sz-p Date: Tue, 24 Sep 2024 19:20:49 +0800 Subject: [PATCH 1/3] fix: #20363 The polar coord clip should include center point in scatter --- src/coord/polar/Polar.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coord/polar/Polar.ts b/src/coord/polar/Polar.ts index e7b9db6cce..43f63a75f4 100644 --- a/src/coord/polar/Polar.ts +++ b/src/coord/polar/Polar.ts @@ -228,12 +228,12 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster { // Start angle and end angle don't matter const dx = x - this.cx; const dy = y - this.cy; - // minus a tiny value 1e-4 to avoid being clipped unexpectedly - const d2 = dx * dx + dy * dy - 1e-4; + const d2 = dx * dx + dy * dy; const r = this.r; const r0 = this.r0; - return d2 <= r * r && d2 >= r0 * r0; + // minus a tiny value 1e-4 in double side to avoid being clipped unexpectedly + return (d2 - 1e-4) <= r * r && (d2 + 1e-4) >= r0 * r0; } }; } From b0ef6c80205978149f01d54c317ea8789649b819 Mon Sep 17 00:00:00 2001 From: sz-p Date: Tue, 24 Sep 2024 19:21:08 +0800 Subject: [PATCH 2/3] test: #20363 The polar coord clip should include center point in scatter --- test/clip.html | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/clip.html b/test/clip.html index 508375bfac..977bc8fa98 100644 --- a/test/clip.html +++ b/test/clip.html @@ -1434,5 +1434,44 @@ }); }); + +
+ From 80438d224e55d7e0ce6f542af6574aa6a0878d3b Mon Sep 17 00:00:00 2001 From: sz-p Date: Wed, 25 Sep 2024 20:02:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20The=20polar=20c?= =?UTF-8?q?oord=20clip=20should=20include=20center=20point=20in=20scatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/polar/Polar.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coord/polar/Polar.ts b/src/coord/polar/Polar.ts index 43f63a75f4..b34d0a8f92 100644 --- a/src/coord/polar/Polar.ts +++ b/src/coord/polar/Polar.ts @@ -214,7 +214,7 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster { const angleExtent = angleAxis.getExtent(); const RADIAN = Math.PI / 180; - + const EPSILON = 1e-4; return { cx: this.cx, cy: this.cy, @@ -233,7 +233,8 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster { const r0 = this.r0; // minus a tiny value 1e-4 in double side to avoid being clipped unexpectedly - return (d2 - 1e-4) <= r * r && (d2 + 1e-4) >= r0 * r0; + // r == r0 contain nothing + return r !== r0 && (d2 - EPSILON) <= r * r && (d2 + EPSILON) >= r0 * r0; } }; }