Skip to content

Commit eeaf52e

Browse files
authored
Merge pull request #20194 from apache/fix/customValues
fix(axis): fix ticks overflowing grid area with dataZoom
2 parents 11c5a12 + 5fb9e9d commit eeaf52e

File tree

2 files changed

+193
-2
lines changed

2 files changed

+193
-2
lines changed

src/coord/axisTickLabelBuilder.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ export function createAxisLabels(axis: Axis): {
8484
const custom = axis.getLabelModel().get('customValues');
8585
if (custom) {
8686
const labelFormatter = makeLabelFormatter(axis);
87+
const extent = axis.scale.getExtent();
88+
const tickNumbers = tickValuesToNumbers(axis, custom);
89+
const ticks = zrUtil.filter(tickNumbers, val => val >= extent[0] && val <= extent[1]);
8790
return {
88-
labels: tickValuesToNumbers(axis, custom).map(numval => {
91+
labels: zrUtil.map(ticks, numval => {
8992
const tick = {value: numval};
9093
return {
9194
formattedLabel: labelFormatter(tick),
@@ -115,8 +118,10 @@ export function createAxisTicks(axis: Axis, tickModel: AxisBaseModel): {
115118
} {
116119
const custom = axis.getTickModel().get('customValues');
117120
if (custom) {
121+
const extent = axis.scale.getExtent();
122+
const tickNumbers = tickValuesToNumbers(axis, custom);
118123
return {
119-
ticks: tickValuesToNumbers(axis, custom)
124+
ticks: zrUtil.filter(tickNumbers, val => val >= extent[0] && val <= extent[1])
120125
};
121126
}
122127
// Only ordinal scale support tick interval

test/axis-customTicks.html

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)