提交 fdcc88d1 编写于 作者: P pissang

fix(treemap): fix treemap label displayed text

上级 91859915
......@@ -46,6 +46,7 @@ interface BreadcrumbItemStyleOption extends ItemStyleOption {
interface TreemapSeriesLabelOption extends LabelOption {
ellipsis?: boolean
formatter?: string | ((params: CallbackDataParams) => string)
}
interface TreemapSeriesItemStyleOption extends ItemStyleOption {
......
......@@ -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(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册