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/04 02:34:22 UTC
[incubator-echarts] branch label-enhancement updated: fix(label):
fix logic issues in setLabelLineStyle
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 6f57d74 fix(label): fix logic issues in setLabelLineStyle
6f57d74 is described below
commit 6f57d74131736e07011e77ea530b37b86f94e7b2
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Jun 4 10:33:36 2020 +0800
fix(label): fix logic issues in setLabelLineStyle
---
src/label/labelGuideHelper.ts | 47 ++++++++++++++++++++++++++++---------------
1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/src/label/labelGuideHelper.ts b/src/label/labelGuideHelper.ts
index c3cbc90..3eee3bc 100644
--- a/src/label/labelGuideHelper.ts
+++ b/src/label/labelGuideHelper.ts
@@ -457,6 +457,28 @@ export function limitTurnAngle(linePoints: number[][], minTurnAngle: number) {
type LabelLineModel = Model<LabelLineOption>;
+
+function setLabelLineState(
+ labelLine: Polyline,
+ ignore: boolean,
+ stateName: string,
+ stateModel: Model
+) {
+ const isNormal = stateName === 'normal';
+ const stateObj = isNormal ? labelLine : labelLine.ensureState(stateName);
+ // Make sure display.
+ stateObj.ignore = ignore;
+ // Set smooth
+ let smooth = stateModel.get('smooth');
+ if (smooth && smooth === true) {
+ smooth = 0.4;
+ }
+ stateObj.shape = stateObj.shape || {};
+ (stateObj.shape as Polyline['shape']).smooth = smooth as number;
+
+ const styleObj = stateModel.getModel('lineStyle').getLineStyle();
+ isNormal ? labelLine.useStyle(styleObj) : stateObj.style = styleObj;
+}
/**
* Create a label line if necessary and set it's style.
*/
@@ -478,7 +500,7 @@ export function setLabelLineStyle(
const normalModel = statesModels.normal;
const showNormal = normalModel.get('show');
- const labelShowNormal = label.ignore;
+ const labelIgnoreNormal = label.ignore;
for (let i = 0; i < STATES.length; i++) {
const stateName = STATES[i];
@@ -487,8 +509,8 @@ export function setLabelLineStyle(
if (stateModel) {
const stateShow = stateModel.get('show');
const isLabelIgnored = isNormal
- ? labelShowNormal
- : retrieve2(label.states && label.states[stateName].ignore, labelShowNormal);
+ ? labelIgnoreNormal
+ : retrieve2(label.states && label.states[stateName].ignore, labelIgnoreNormal);
if (isLabelIgnored // Not show when label is not shown in this state.
|| !retrieve2(stateShow, showNormal) // Use normal state by default if not set.
) {
@@ -502,21 +524,14 @@ export function setLabelLineStyle(
if (!labelLine) {
labelLine = new Polyline();
targetEl.setTextGuideLine(labelLine);
+ // Reset state of normal because it's new created.
+ // NOTE: NORMAL should always been the first!
+ if (!isNormal && (labelIgnoreNormal || !showNormal)) {
+ setLabelLineState(labelLine, true, 'normal', statesModels.normal);
+ }
}
- const stateObj = isNormal ? labelLine : labelLine.ensureState(stateName);
- // Make sure display.
- stateObj.ignore = false;
- // Set smooth
- let smooth = stateModel.get('smooth');
- if (smooth && smooth === true) {
- smooth = 0.4;
- }
- stateObj.shape = stateObj.shape || {};
- (stateObj.shape as Polyline['shape']).smooth = smooth as number;
-
- const styleObj = stateModel.getModel('lineStyle').getLineStyle();
- isNormal ? labelLine.useStyle(styleObj) : stateObj.style = styleObj;
+ setLabelLineState(labelLine, false, stateName, stateModel);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org