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/03/24 08:47:24 UTC

[incubator-echarts] branch next updated: refact: fix default label color strategy

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

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


The following commit(s) were added to refs/heads/next by this push:
     new 9e36657  refact: fix default label color strategy
9e36657 is described below

commit 9e36657faca10d7f949e565fcc9f705f60c77725
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Mar 24 16:47:01 2020 +0800

    refact: fix default label color strategy
---
 src/chart/helper/Line.ts | 10 ++++------
 src/echarts.ts           |  8 ++++++++
 src/util/graphic.ts      | 29 ++++++++++++++++++++---------
 3 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/src/chart/helper/Line.ts b/src/chart/helper/Line.ts
index 6598247..8d13c3d 100644
--- a/src/chart/helper/Line.ts
+++ b/src/chart/helper/Line.ts
@@ -257,19 +257,17 @@ class Line extends graphic.Group {
             )
             : null;
 
-        let labelStyle = label.style;
-
         // Always set `textStyle` even if `normalStyle.text` is null, because default
         // values have to be set on `normalStyle`.
         if (normalText != null || emphasisText != null) {
-            graphic.setTextStyle(label.style, null, labelModel, {
+            label.useStyle(graphic.createTextStyle(labelModel, {
                 text: normalText as string
             }, {
                 autoColor: defaultLabelColor
-            });
+            }));
 
-            label.__align = labelStyle.align;
-            label.__verticalAlign = labelStyle.verticalAlign;
+            label.__align = label.style.align;
+            label.__verticalAlign = label.style.verticalAlign;
             // 'start', 'middle', 'end'
             label.__position = labelModel.get('position') || 'middle';
 
diff --git a/src/echarts.ts b/src/echarts.ts
index 931fb73..dc07807 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -1711,6 +1711,14 @@ class ECharts extends Eventful {
                 if (el.type !== 'group') {
                     z != null && (el.z = z);
                     zlevel != null && (el.zlevel = zlevel);
+
+                    const textContent = el.getTextContent();
+                    if (textContent) {
+                        textContent.z = z;
+                        textContent.zlevel = zlevel;
+                        // lift z2 of text content
+                        textContent.z2 = el.z2 + 1;
+                    }
                 }
             });
         };
diff --git a/src/util/graphic.ts b/src/util/graphic.ts
index 84cc326..3977d9e 100644
--- a/src/util/graphic.ts
+++ b/src/util/graphic.ts
@@ -385,6 +385,10 @@ function singleEnterEmphasis(el: Displayable) {
     }
 
     el.z2 += Z2_EMPHASIS_LIFT;
+    const textContent = el.getTextContent();
+    if (textContent) {
+        textContent.z2 += Z2_EMPHASIS_LIFT;
+    }
 
     // TODO hover layer
 }
@@ -659,13 +663,16 @@ export function setLabelStyle<LDI>(
         const normalStyle = createTextStyle(
             normalModel,
             normalSpecified,
-            opt
+            opt,
+            false,
+            !isSetOnRichText
         );
         emphasisState.style = createTextStyle(
             emphasisModel,
             emphasisSpecified,
             opt,
-            true
+            true,
+            !isSetOnRichText
         );
 
         if (!isSetOnRichText) {
@@ -706,10 +713,11 @@ export function createTextStyle(
     textStyleModel: Model,
     specifiedTextStyle?: RichTextStyleProps,    // Can be overrided by settings in model.
     opt?: TextCommonParams,
-    isEmphasis?: boolean
+    isEmphasis?: boolean,
+    isAttached?: boolean // If text is attached on an element. If so, auto color will handling in zrender.
 ) {
     const textStyle: RichTextStyleProps = {};
-    setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis);
+    setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis, isAttached);
     specifiedTextStyle && extend(textStyle, specifiedTextStyle);
     // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
 
@@ -758,6 +766,7 @@ export function createTextConfig(
     // fill and auto is determined by the color of path fill if it's not specified by developers.
     if (!textStyle.fill) {
         textConfig.insideFill = 'auto';
+        textConfig.outsideFill = opt.autoColor || null;
     }
     if (!textStyle.stroke) {
         textConfig.insideStroke = 'auto';
@@ -784,7 +793,8 @@ function setTextStyleCommon(
     textStyle: RichTextStyleProps,
     textStyleModel: Model,
     opt?: TextCommonParams,
-    isEmphasis?: boolean
+    isEmphasis?: boolean,
+    isAttached?: boolean
 ) {
     // Consider there will be abnormal when merge hover style to normal style if given default value.
     opt = opt || EMPTY_OBJ;
@@ -819,7 +829,7 @@ function setTextStyleCommon(
                 // the default color `'blue'` will not be adopted if no color declared in `rich`.
                 // That might confuses users. So probably we should put `textStyleModel` as the
                 // root ancestor of the `richTextStyle`. But that would be a break change.
-                setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
+                setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis, isAttached);
             }
         }
     }
@@ -832,7 +842,7 @@ function setTextStyleCommon(
         textStyle.overflow = overflow;
     }
 
-    setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
+    setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, isAttached, true);
 
     // TODO
     if (opt.forceRich && !opt.textStyle) {
@@ -894,6 +904,7 @@ function setTokenTextStyle(
     globalTextStyle: LabelOption,
     opt?: TextCommonParams,
     isEmphasis?: boolean,
+    isAttached?: boolean,
     isBlock?: boolean
 ) {
     // In merge mode, default value should not be given.
@@ -925,8 +936,8 @@ function setTokenTextStyle(
         textStyle.lineWidth = lineWidth;
     }
 
-
-    if (!isEmphasis) {
+    // TODO
+    if (!isEmphasis && !isAttached) {
         // Set default finally.
         if (textStyle.fill == null && opt.autoColor) {
             textStyle.fill = opt.autoColor;


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