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/04/24 06:26:27 UTC

[incubator-echarts] 02/02: fix(label): respect the original ignore value when handling overlap

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

commit 9718d12b5097aa9a28b262dd93af63b406becce1
Author: pissang <bm...@gmail.com>
AuthorDate: Fri Apr 24 14:26:05 2020 +0800

    fix(label): respect the original ignore value when handling overlap
---
 src/util/LabelManager.ts | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/util/LabelManager.ts b/src/util/LabelManager.ts
index 0cdf2f3..a91daca 100644
--- a/src/util/LabelManager.ts
+++ b/src/util/LabelManager.ts
@@ -58,6 +58,8 @@ interface LabelLayoutDesc {
 }
 
 interface SavedLabelAttr {
+    ignore: boolean
+
     x: number
     y: number
     rotation: number
@@ -111,7 +113,12 @@ class LabelManager {
      * @param label
      * @param layoutOption
      */
-    addLabel(dataIndex: number, seriesIndex: number, label: ZRText, layoutOption: LabelLayoutDesc['layoutOption']) {
+    addLabel(
+        dataIndex: number,
+        seriesIndex: number,
+        label: ZRText,
+        layoutOption: LabelLayoutDesc['layoutOption']
+    ) {
         const labelStyle = label.style;
         const hostEl = label.__hostTarget;
         const textConfig = hostEl.textConfig || {};
@@ -148,6 +155,8 @@ class LabelManager {
             // Save default label attributes.
             // For restore if developers want get back to default value in callback.
             defaultAttr: {
+                ignore: label.ignore,
+
                 x: dummyTransformable.x,
                 y: dummyTransformable.y,
                 rotation: dummyTransformable.rotation,
@@ -290,13 +299,12 @@ class LabelManager {
             if (overlapped) {
                 // label.setStyle({ opacity: 0.1 });
                 // label.z = 0;
-                // Use invisible instead of ignore because ignored label won't be updated in the host.
-                label.attr('invisible', true);
+                label.hide();
             }
             else {
                 // TODO Restore z
                 // label.setStyle({ opacity: 1 });
-                label.attr('invisible', false);
+                label.attr('ignore', labelItem.defaultAttr.ignore);
 
                 displayedLabels.push({
                     label,


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