From 134fd5fe584269bdc0755abf02224116f1c63ddc Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Wed, 21 Jul 2021 23:10:05 +0800 Subject: [PATCH 1/2] Feat: label support lineOverflow and ellipsis --- src/chart/treemap/TreemapSeries.ts | 4 ++-- src/label/labelStyle.ts | 2 +- src/util/types.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/chart/treemap/TreemapSeries.ts b/src/chart/treemap/TreemapSeries.ts index efc0f06aa1..8822ed0fe7 100644 --- a/src/chart/treemap/TreemapSeries.ts +++ b/src/chart/treemap/TreemapSeries.ts @@ -55,7 +55,7 @@ interface BreadcrumbItemStyleOption extends ItemStyleOption { } interface TreemapSeriesLabelOption extends SeriesLabelOption { - ellipsis?: boolean + ellipsis?: string formatter?: string | ((params: CallbackDataParams) => string) } @@ -306,7 +306,7 @@ class TreemapSeriesModel extends SeriesModel { upperLabel: { show: true, position: [0, '50%'], - ellipsis: true, + ellipsis: '...', verticalAlign: 'middle' } }, diff --git a/src/label/labelStyle.ts b/src/label/labelStyle.ts index def6b19f1b..82721078f0 100644 --- a/src/label/labelStyle.ts +++ b/src/label/labelStyle.ts @@ -462,7 +462,7 @@ const TEXT_PROPS_WITH_GLOBAL = [ 'textShadowColor', 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY' ] as const; const TEXT_PROPS_SELF = [ - 'align', 'lineHeight', 'width', 'height', 'tag', 'verticalAlign' + 'align', 'lineHeight', 'width', 'height', 'tag', 'verticalAlign', 'lineOverflow', 'ellipsis' ] as const; const TEXT_PROPS_BOX = [ 'padding', 'borderWidth', 'borderRadius', 'borderDashOffset', diff --git a/src/util/types.ts b/src/util/types.ts index 82a691fee0..1d690e047b 100644 --- a/src/util/types.ts +++ b/src/util/types.ts @@ -1109,6 +1109,8 @@ export interface LabelOption extends TextCommonOption { // formatter?: string | ((params: CallbackDataParams) => string) rich?: Dictionary + lineOverflow?: 'truncate' + ellipsis?: string } export interface SeriesLabelOption extends LabelOption { From c2f2bbc8b94c68c77f01a0350072465759a271af Mon Sep 17 00:00:00 2001 From: susiwen8 Date: Wed, 21 Jul 2021 23:11:13 +0800 Subject: [PATCH 2/2] Fix(title): title should have lineOverflow --- src/component/title/install.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/component/title/install.ts b/src/component/title/install.ts index c7e0678a02..fb5126d11b 100644 --- a/src/component/title/install.ts +++ b/src/component/title/install.ts @@ -158,7 +158,8 @@ class TitleView extends ComponentView { const textEl = new graphic.Text({ style: createTextStyle(textStyleModel, { text: titleModel.get('text'), - fill: textStyleModel.getTextColor() + fill: textStyleModel.getTextColor(), + lineOverflow: textStyleModel.get('lineOverflow') }, {disableBox: true}), z2: 10 }); @@ -171,7 +172,8 @@ class TitleView extends ComponentView { text: subText, fill: subtextStyleModel.getTextColor(), y: textRect.height + titleModel.get('itemGap'), - verticalAlign: 'top' + verticalAlign: 'top', + lineOverflow: textStyleModel.get('lineOverflow') }, {disableBox: true}), z2: 10 });