You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/11/16 01:44:06 UTC
[echarts] 01/01: fix(line): fix bezier cp calculate wrong in monotone smooth
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch fix-smooth-monotone
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit d999fd15bb83e02594182d8fc276ef27e32ac6fa
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Nov 16 09:43:00 2021 +0800
fix(line): fix bezier cp calculate wrong in monotone smooth
---
src/chart/line/poly.ts | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/chart/line/poly.ts b/src/chart/line/poly.ts
index ed38bed..181c215 100644
--- a/src/chart/line/poly.ts
+++ b/src/chart/line/poly.ts
@@ -136,18 +136,20 @@ function drawSegment(
if (smoothMonotone === 'x') {
lenPrevSeg = Math.abs(dx0);
lenNextSeg = Math.abs(dx1);
- cpx1 = x - lenPrevSeg * smooth;
+ const dir = vx > 0 ? 1 : -1;
+ cpx1 = x - dir * lenPrevSeg * smooth;
cpy1 = y;
- nextCpx0 = x + lenPrevSeg * smooth;
+ nextCpx0 = x + dir * lenNextSeg * smooth;
nextCpy0 = y;
}
else if (smoothMonotone === 'y') {
lenPrevSeg = Math.abs(dy0);
lenNextSeg = Math.abs(dy1);
+ const dir = vy > 0 ? 1 : -1;
cpx1 = x;
- cpy1 = y - lenPrevSeg * smooth;
+ cpy1 = y - dir * lenPrevSeg * smooth;
nextCpx0 = x;
- nextCpy0 = y + lenPrevSeg * smooth;
+ nextCpy0 = y + dir * lenNextSeg * smooth;
}
else {
lenPrevSeg = Math.sqrt(dx0 * dx0 + dy0 * dy0);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org