From 08fb397c3210a115c952e0f238eb5f7ef4395737 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Wed, 4 Dec 2024 17:36:05 +0800 Subject: [PATCH 1/3] fix(pictorial): fix zero value flipping for different axes --- src/chart/bar/PictorialBarView.ts | 4 +- test/pictorial-zero-value.html | 102 ++++++++++++++++++++---------- 2 files changed, 73 insertions(+), 33 deletions(-) diff --git a/src/chart/bar/PictorialBarView.ts b/src/chart/bar/PictorialBarView.ts index 0872d7b62a..d834bffc0e 100644 --- a/src/chart/bar/PictorialBarView.ts +++ b/src/chart/bar/PictorialBarView.ts @@ -341,7 +341,9 @@ function prepareBarLength( // if 'pxSign' means sign of pixel, it can't be zero, or symbolScale will be zero // and when borderWidth be settled, the actual linewidth will be NaN - outputSymbolMeta.pxSign = boundingLength >= 0 ? 1 : -1; + outputSymbolMeta.pxSign = (valueDim.xy === 'x' !== valueAxis.inverse) + ? boundingLength >= 0 ? 1 : -1 + : boundingLength > 0 ? 1 : -1; } function convertToCoordOnAxis(axis: Axis2D, value: number) { diff --git a/test/pictorial-zero-value.html b/test/pictorial-zero-value.html index 7a7b924895..aa42e541bb 100644 --- a/test/pictorial-zero-value.html +++ b/test/pictorial-zero-value.html @@ -1,3 +1,4 @@ + + - + + - - - + + + + - + + + -
+
+
+
- + + + From 5a1be948971b789d912376e51f0f474b7b6b553f Mon Sep 17 00:00:00 2001 From: Ovilia Date: Wed, 4 Dec 2024 18:29:28 +0800 Subject: [PATCH 2/3] refactor(pictorial): refactor xor logic --- src/chart/bar/PictorialBarView.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chart/bar/PictorialBarView.ts b/src/chart/bar/PictorialBarView.ts index d834bffc0e..43e2da9d89 100644 --- a/src/chart/bar/PictorialBarView.ts +++ b/src/chart/bar/PictorialBarView.ts @@ -341,7 +341,9 @@ function prepareBarLength( // if 'pxSign' means sign of pixel, it can't be zero, or symbolScale will be zero // and when borderWidth be settled, the actual linewidth will be NaN - outputSymbolMeta.pxSign = (valueDim.xy === 'x' !== valueAxis.inverse) + const isXAxis = valueDim.xy === 'x'; + const isInverse = valueAxis.inverse; + outputSymbolMeta.pxSign = (isXAxis && !isInverse || !isXAxis && isInverse) ? boundingLength >= 0 ? 1 : -1 : boundingLength > 0 ? 1 : -1; } From 6e9ef3b50a58332de19cf6f64922c3f1561c2d64 Mon Sep 17 00:00:00 2001 From: Zhongxiang Wang Date: Wed, 4 Dec 2024 18:51:04 +0800 Subject: [PATCH 3/3] style(pictorialBar): make pxSign logic more intuitive --- src/chart/bar/PictorialBarView.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/bar/PictorialBarView.ts b/src/chart/bar/PictorialBarView.ts index 43e2da9d89..8eacd4ca54 100644 --- a/src/chart/bar/PictorialBarView.ts +++ b/src/chart/bar/PictorialBarView.ts @@ -343,7 +343,7 @@ function prepareBarLength( // and when borderWidth be settled, the actual linewidth will be NaN const isXAxis = valueDim.xy === 'x'; const isInverse = valueAxis.inverse; - outputSymbolMeta.pxSign = (isXAxis && !isInverse || !isXAxis && isInverse) + outputSymbolMeta.pxSign = (isXAxis && !isInverse) || (!isXAxis && isInverse) ? boundingLength >= 0 ? 1 : -1 : boundingLength > 0 ? 1 : -1; }