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/10 11:04:26 UTC
[incubator-echarts] branch label-enhancement updated: fix(treemap):
fix treemap label displayed text
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 fdcc88d fix(treemap): fix treemap label displayed text
fdcc88d is described below
commit fdcc88d1c9b524812c54b6e5132d838a415aeb10
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Jun 10 19:04:08 2020 +0800
fix(treemap): fix treemap label displayed text
---
src/chart/treemap/TreemapSeries.ts | 1 +
src/chart/treemap/TreemapView.ts | 20 ++++++++++----------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/chart/treemap/TreemapSeries.ts b/src/chart/treemap/TreemapSeries.ts
index 2f6d860..532fd3d 100644
--- a/src/chart/treemap/TreemapSeries.ts
+++ b/src/chart/treemap/TreemapSeries.ts
@@ -46,6 +46,7 @@ interface BreadcrumbItemStyleOption extends ItemStyleOption {
interface TreemapSeriesLabelOption extends LabelOption {
ellipsis?: boolean
+ formatter?: string | ((params: CallbackDataParams) => string)
}
interface TreemapSeriesItemStyleOption extends ItemStyleOption {
diff --git a/src/chart/treemap/TreemapView.ts b/src/chart/treemap/TreemapView.ts
index 595d51a..b490cb5 100644
--- a/src/chart/treemap/TreemapView.ts
+++ b/src/chart/treemap/TreemapView.ts
@@ -52,9 +52,9 @@ const Group = graphic.Group;
const Rect = graphic.Rect;
const DRAG_THRESHOLD = 3;
-const PATH_LABEL_NOAMAL = ['label'] as const;
+const PATH_LABEL_NOAMAL = 'label';
const PATH_LABEL_EMPHASIS = ['emphasis', 'label'] as const;
-const PATH_UPPERLABEL_NORMAL = ['upperLabel'] as const;
+const PATH_UPPERLABEL_NORMAL = 'upperLabel';
const PATH_UPPERLABEL_EMPHASIS = ['emphasis', 'upperLabel'] as const;
const Z_BASE = 10; // Should bigger than every z.
const Z_BG = 1;
@@ -912,9 +912,16 @@ function renderNode(
height: number,
upperLabelRect?: RectLike
) {
+ const normalLabelModel = nodeModel.getModel(
+ upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
+ );
+ const emphasisLabelModel = nodeModel.getModel(
+ upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS
+ );
+
let text = retrieve(
seriesModel.getFormattedLabel(
- thisNode.dataIndex, 'normal', null, null, upperLabelRect ? 'upperLabel' : 'label'
+ thisNode.dataIndex, 'normal', null, null, normalLabelModel.get('formatter')
),
nodeModel.get('name')
);
@@ -923,13 +930,6 @@ function renderNode(
text = iconChar ? iconChar + ' ' + text : text;
}
- const normalLabelModel = nodeModel.getModel(
- upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL
- );
- const emphasisLabelModel = nodeModel.getModel(
- upperLabelRect ? PATH_UPPERLABEL_EMPHASIS : PATH_LABEL_EMPHASIS
- );
-
const isShow = normalLabelModel.getShallow('show');
graphic.setLabelStyle(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org