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 2020/06/21 10:07:02 UTC

[incubator-echarts] branch label-enhancement updated: fix(label): fix wrong squeeze logic in label layout

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch label-enhancement
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/label-enhancement by this push:
     new 27f2044  fix(label): fix wrong squeeze logic in label layout
27f2044 is described below

commit 27f20445a0311f8cf09168b09221d1a625659ef4
Author: pissang <bm...@gmail.com>
AuthorDate: Sun Jun 21 18:06:43 2020 +0800

    fix(label): fix wrong squeeze logic in label layout
---
 src/label/labelLayoutHelper.ts | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/label/labelLayoutHelper.ts b/src/label/labelLayoutHelper.ts
index 644091e..cb2bf9a 100644
--- a/src/label/labelLayoutHelper.ts
+++ b/src/label/labelLayoutHelper.ts
@@ -202,16 +202,20 @@ function shiftLayout(
             delta = totalGaps * (delta < 0 ? -1 : 1);
         }
 
-        for (let i = 0; i < len - 1; i++) {
-            // Distribute the shift delta to all gaps.
-            const movement = gaps[i] / totalGaps * delta;
-            if (delta > 0) {
+        if (delta > 0) {
+            for (let i = 0; i < len - 1; i++) {
+                // Distribute the shift delta to all gaps.
+                const movement = gaps[i] / totalGaps * delta;
                 // Forward
                 shiftList(movement, 0, i + 1);
             }
-            else {
-                // Backward
-                shiftList(movement, len - i - 1, len);
+        }
+        else {
+            // Backward
+            for (let i = len - 1; i > 0; i--) {
+                // Distribute the shift delta to all gaps.
+                const movement = gaps[i - 1] / totalGaps * delta;
+                shiftList(movement, i, len);
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org