This is an automated email from the ASF dual-hosted git repository. shenyi pushed a commit to branch axis-hide-overlap in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 7dbf36c40a91e2ecf3a7af8a20ed029df9a76574 Author: pissang <bm2736...@gmail.com> AuthorDate: Mon Sep 13 16:13:07 2021 +0800 fix(time): add `axisLabel.hideOverlap` --- src/component/axis/AxisBuilder.ts | 4 ++-- src/coord/axisCommonTypes.ts | 25 ++++++++++++++++--------- test/timeScale.html | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/component/axis/AxisBuilder.ts b/src/component/axis/AxisBuilder.ts index 6fad867..d06c0b5 100644 --- a/src/component/axis/AxisBuilder.ts +++ b/src/component/axis/AxisBuilder.ts @@ -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, diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index 0997f67..509173c 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -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. @@ -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) } diff --git a/test/timeScale.html b/test/timeScale.html index cf9bfc2..47370f0 100644 --- a/test/timeScale.html +++ b/test/timeScale.html @@ -153,6 +153,7 @@ under the License. min: 'dataMin', max: 'dataMax', axisLabel: { + hideOverlap: true } } ], --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org For additional commands, e-mail: commits-h...@echarts.apache.org