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/23 04:46:55 UTC

[incubator-echarts] branch label-enhancement updated: fix(label): label color is dark by default in pie and sunburst.

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 83df54f  fix(label): label color is dark by default in pie and sunburst.
83df54f is described below

commit 83df54fa3997ccd1b91b63ee397a0579ce0aba12
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jun 23 12:46:38 2020 +0800

    fix(label): label color is dark by default in pie and sunburst.
---
 src/chart/pie/PieSeries.ts          |  2 +-
 src/chart/pie/PieView.ts            | 14 ++++++++------
 src/chart/sunburst/SunburstPiece.ts |  4 +---
 test/aria-pie.html                  |  1 +
 test/label-layout.html              |  2 +-
 test/sunburst-drink.html            |  3 +++
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/chart/pie/PieSeries.ts b/src/chart/pie/PieSeries.ts
index 01a828c..439a5bd 100644
--- a/src/chart/pie/PieSeries.ts
+++ b/src/chart/pie/PieSeries.ts
@@ -244,7 +244,7 @@ class PieSeriesModel extends SeriesModel<PieSeriesOption> {
         height: null,
 
         label: {
-            color: 'inherit',
+            // color: 'inherit',
             // If rotate around circle
             rotate: 0,
             show: true,
diff --git a/src/chart/pie/PieView.ts b/src/chart/pie/PieView.ts
index 1598a95..6131727 100644
--- a/src/chart/pie/PieView.ts
+++ b/src/chart/pie/PieView.ts
@@ -26,9 +26,10 @@ import GlobalModel from '../../model/Global';
 import ExtensionAPI from '../../ExtensionAPI';
 import { Payload, ColorString, ECElement } from '../../util/types';
 import List from '../../data/List';
-import PieSeriesModel, {PieDataItemOption} from './PieSeries';
+import PieSeriesModel, {PieDataItemOption, PieSeriesOption} from './PieSeries';
 import labelLayout from './labelLayout';
 import { setLabelLineStyle } from '../../label/labelGuideHelper';
+import Model from '../../model/Model';
 
 function updateDataSelected(
     this: PiePiece,
@@ -176,9 +177,9 @@ class PiePiece extends graphic.Sector {
         const visualColor = style && style.fill as ColorString;
 
         graphic.setLabelStyle(
-            labelText,
-            labelModel,
-            labelHoverModel,
+            sector,
+            labelModel as Model<Omit<PieSeriesOption['label'], 'position' | 'rotate'>>, // position / rotate won't be used.
+            labelHoverModel as Model<Omit<PieSeriesOption['label'], 'position' | 'rotate'>>,
             {
                 labelFetcher: data.hostModel as PieSeriesModel,
                 labelDataIndex: idx,
@@ -193,8 +194,9 @@ class PiePiece extends graphic.Sector {
 
         // Set textConfig on sector.
         sector.setTextConfig({
-            local: true,
-            outsideFill: labelModel.get('color') === 'inherit' ? visualColor : 'auto'
+            // reset position, rotation
+            position: null,
+            rotation: null
         });
 
         // Make sure update style on labelText after setLabelStyle.
diff --git a/src/chart/sunburst/SunburstPiece.ts b/src/chart/sunburst/SunburstPiece.ts
index b2c0a14..00daa35 100644
--- a/src/chart/sunburst/SunburstPiece.ts
+++ b/src/chart/sunburst/SunburstPiece.ts
@@ -231,11 +231,9 @@ class SunburstPiece extends graphic.Sector {
             const sectorState = isNormal ? sector : sector.states[stateName];
             const labelColor = sectorState.style.fill as ColorString;
             sectorState.textConfig = {
+                outsideFill: labelStateModel.get('color') === 'inherit' ? labelColor : null,
                 inside: labelPosition !== 'outside'
             };
-            if (labelColor) {
-                sectorState.textConfig.insideStroke = sectorState.textConfig.outsideFill = labelColor;
-            }
 
             let r;
             const labelPadding = getLabelAttr(labelStateModel, 'distance') || 0;
diff --git a/test/aria-pie.html b/test/aria-pie.html
index c324210..c62310c 100644
--- a/test/aria-pie.html
+++ b/test/aria-pie.html
@@ -98,6 +98,7 @@ under the License.
                             type: 'pie',
                             radius : '55%',
                             center: ['50%', '60%'],
+                            selectedMode: 'single',
                             data:[
                                 {value:335, name:'直接访问'},
                                 {value:310, name:'邮件营销'},
diff --git a/test/label-layout.html b/test/label-layout.html
index 72eaf1a..941d377 100644
--- a/test/label-layout.html
+++ b/test/label-layout.html
@@ -307,6 +307,7 @@ under the License.
                             type: 'pie',
                             radius: ['50%', '70%'],
                             label: {
+                                color: 'inherit',
                                 show: false
                             },
                             emphasis: {
@@ -450,7 +451,6 @@ under the License.
                             formatter: function (param) {
                                 return param.data[3];
                             },
-                            color: '#333',
                             textBorderColor: '#fff',
                             textBorderWidth: 1,
                             position: 'top'
diff --git a/test/sunburst-drink.html b/test/sunburst-drink.html
index e86cbf7..b6b49e6 100644
--- a/test/sunburst-drink.html
+++ b/test/sunburst-drink.html
@@ -713,6 +713,9 @@ under the License.
                         data: data,
                         radius: [0, '95%'],
                         sort: null,
+                        label: {
+                            color: 'inherit'
+                        },
                         levels: [{}, {
                             r0: '15%',
                             r: '35%',


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