Skip to content

Commit

Permalink
fix(time): add axisLabel.hideOverlap
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Sep 13, 2021
1 parent 01bf5f1 commit 7dbf36c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/component/axis/AxisBuilder.ts
Expand Up @@ -349,9 +349,9 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu

buildAxisMinorTicks(group, transformGroup, axisModel, opt.tickDirection);

// This bit fixes the label overlap issue for the Time chart.
// This bit fixes the label overlap issue for the time chart.
// See https://github.com/apache/echarts/issues/14266 for more.
if (axisModel.get('type') === 'time') {
if (axisModel.get(['axisLabel', 'hideOverlap'])) {
const labelList = prepareLayoutList(map(labelEls, label => ({
label,
priority: label.z2,
Expand Down
25 changes: 16 additions & 9 deletions src/coord/axisCommonTypes.ts
Expand Up @@ -64,15 +64,19 @@ export interface AxisBaseOptionCommon extends ComponentOption,
minorSplitLine?: MinorSplitLineOption;
splitArea?: SplitAreaOption;

// Min value of the axis. can be:
// + ScaleDataValue
// + 'dataMin': use the min value in data.
// + null/undefined: auto decide min value (consider pretty look and boundaryGap).
/**
* Min value of the axis. can be:
* + ScaleDataValue
* + 'dataMin': use the min value in data.
* + null/undefined: auto decide min value (consider pretty look and boundaryGap).
*/
min?: ScaleDataValue | 'dataMin' | ((extent: {min: number, max: number}) => ScaleDataValue);
// Max value of the axis. can be:
// + ScaleDataValue
// + 'dataMax': use the max value in data.
// + null/undefined: auto decide max value (consider pretty look and boundaryGap).
/**
* Max value of the axis. can be:
* + ScaleDataValue
* + 'dataMax': use the max value in data.
* + null/undefined: auto decide max value (consider pretty look and boundaryGap).
*/
max?: ScaleDataValue | 'dataMax' | ((extent: {min: number, max: number}) => ScaleDataValue);
// Optional value can be:
// + `false`: always include value 0.
Expand Down Expand Up @@ -209,7 +213,10 @@ interface AxisLabelBaseOption extends Omit<TextCommonOption, 'color'> {
showMaxLabel?: boolean,
margin?: number,
rich?: Dictionary<TextCommonOption>

/**
* If hide overlapping labels.
*/
hideOverlap?: boolean;
// Color can be callback
color?: ColorString | ((value?: string | number, index?: number) => ColorString)
}
Expand Down
1 change: 1 addition & 0 deletions test/timeScale.html

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

0 comments on commit 7dbf36c

Please sign in to comment.