Skip to content

Commit

Permalink
fix(axis): axis label width when overflow is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Dec 10, 2021
1 parent 0114414 commit 9ee1a32
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/chart/treemap/TreemapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ interface BreadcrumbItemStyleOption extends ItemStyleOption {
}

interface TreemapSeriesLabelOption extends SeriesLabelOption {
ellipsis?: boolean
formatter?: string | ((params: CallbackDataParams) => string)
}

Expand Down Expand Up @@ -305,7 +304,7 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
upperLabel: {
show: true,
position: [0, '50%'],
ellipsis: true,
overflow: 'truncate',
verticalAlign: 'middle'
}
},
Expand Down
7 changes: 6 additions & 1 deletion src/model/mixin/textStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const PATH_COLOR = ['textStyle', 'color'] as const;
export type LabelFontOption = Pick<LabelOption, 'fontStyle' | 'fontWeight' | 'fontSize' | 'fontFamily'>;
type LabelRectRelatedOption = Pick<LabelOption,
'align' | 'verticalAlign' | 'padding' | 'lineHeight' | 'baseline' | 'rich'
| 'width' | 'height' | 'overflow' | 'ellipsis'
> & LabelFontOption;

// TODO Performance improvement?
Expand Down Expand Up @@ -68,7 +69,11 @@ class TextStyleMixin {
verticalAlign: this.getShallow('verticalAlign') || this.getShallow('baseline'),
padding: this.getShallow('padding') as number[],
lineHeight: this.getShallow('lineHeight'),
rich: this.getShallow('rich')
rich: this.getShallow('rich'),
width: this.getShallow('width') as number,
height: this.getShallow('height') as number,
overflow: this.getShallow('overflow'),
ellipsis: this.getShallow('ellipsis')
});
tmpRichText.update();
return tmpRichText.getBoundingRect();
Expand Down
3 changes: 3 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,9 @@ export interface TextCommonOption extends ShadowOptionMixin {
textShadowOffsetY?: number

tag?: string

overflow?: 'break' | 'breakAll' | 'truncate' | 'none'
ellipsis?: string
}

export interface LabelFormatterCallback<T = CallbackDataParams> {
Expand Down
6 changes: 5 additions & 1 deletion test/bar3.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9ee1a32

Please sign in to comment.