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/02 09:03:55 UTC
[incubator-echarts] branch label-enhancement updated: feat: ignore
labelLayout if it's not specified in option
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 86d6c25 feat: ignore labelLayout if it's not specified in option
86d6c25 is described below
commit 86d6c2535774873b78c792c60a31954dac3b6b32
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jun 2 17:03:18 2020 +0800
feat: ignore labelLayout if it's not specified in option
---
src/chart/pie/PieSeries.ts | 10 ++++++++--
src/label/LabelManager.ts | 15 ++++++++++++---
src/util/types.ts | 8 ++++++--
3 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/src/chart/pie/PieSeries.ts b/src/chart/pie/PieSeries.ts
index e5c398b..e1cfa91 100644
--- a/src/chart/pie/PieSeries.ts
+++ b/src/chart/pie/PieSeries.ts
@@ -224,8 +224,6 @@ class PieSeriesModel extends SeriesModel<PieSeriesOption> {
// 高亮扇区偏移量
hoverOffset: 5,
- // If use strategy to avoid label overlapping
- avoidLabelOverlap: true,
// 选择模式,默认关闭,可选single,multiple
// selectedMode: false,
// 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
@@ -283,6 +281,14 @@ class PieSeriesModel extends SeriesModel<PieSeriesOption> {
borderWidth: 1
},
+ labelLayout: {
+ // Hide the overlapped label.
+ overlap: 'hidden'
+ },
+
+ // If use strategy to avoid label overlapping
+ avoidLabelOverlap: true,
+
// Animation type. Valid values: expansion, scale
animationType: 'expansion',
diff --git a/src/label/LabelManager.ts b/src/label/LabelManager.ts
index d3cdfc5..29cf0de 100644
--- a/src/label/LabelManager.ts
+++ b/src/label/LabelManager.ts
@@ -46,7 +46,7 @@ import Transformable from 'zrender/src/core/Transformable';
import { updateLabelGuideLine } from './labelGuideHelper';
import SeriesModel from '../model/Series';
import { makeInner } from '../util/model';
-import { retrieve2, guid, each } from 'zrender/src/core/util';
+import { retrieve2, guid, each, keys } from 'zrender/src/core/util';
interface DisplayedLabelItem {
label: ZRText
@@ -149,7 +149,7 @@ class LabelManager {
/**
* Add label to manager
*/
- addLabel(
+ private _addLabel(
dataIndex: number,
seriesModel: SeriesModel,
label: ZRText,
@@ -235,7 +235,16 @@ class LabelManager {
this._chartViewList.push(chartView);
const seriesModel = chartView.__model;
+
const layoutOption = seriesModel.get('labelLayout');
+
+ /**
+ * Ignore layouting if it's not specified anything.
+ */
+ if (!layoutOption && !keys(layoutOption).length) {
+ return;
+ }
+
chartView.group.traverse((child) => {
if (child.ignore) {
return true; // Stop traverse descendants.
@@ -245,7 +254,7 @@ class LabelManager {
const textEl = child.getTextContent();
const dataIndex = getECData(child).dataIndex;
if (textEl && dataIndex != null) {
- this.addLabel(dataIndex, seriesModel, textEl, layoutOption);
+ this._addLabel(dataIndex, seriesModel, textEl, layoutOption);
}
});
}
diff --git a/src/util/types.ts b/src/util/types.ts
index 96a82ad..75ae6e3 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -822,6 +822,10 @@ export interface LabelLayoutOptionCallbackParams {
};
export interface LabelLayoutOption {
+ /**
+ * How to handle the element when it's overlapped
+ * @default 'visible'
+ */
overlap?: 'visible' | 'hidden' | 'blur'
/**
* Minimal margin between two labels which will be considered as overlapped.
@@ -1128,13 +1132,13 @@ export interface SeriesOption extends
*/
seriesLayoutBy?: 'column' | 'row'
+ labelLine?: LabelGuideLineOption
+
/**
* Global label layout option in label layout stage.
*/
labelLayout?: LabelLayoutOption | LabelLayoutOptionCallback
- labelLine?: LabelGuideLineOption
-
/**
* Animation config for state transition.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org