Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/coord/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class Axis {
this,
preTicksCoords,
alignWithLabel,
result.tickCategoryInterval,
);

return map(preTicksCoords, function (item) {
Expand Down Expand Up @@ -318,6 +319,7 @@ function fixOnBandTicksCoords(
tick: ScaleTick
}[],
alignWithLabel: boolean,
tickCategoryInterval: number | NullUndefined,
// return: whether coords are modified according to `onBand`.
): boolean {
const ticksLen = preTicksCoords.length;
Expand All @@ -340,15 +342,17 @@ function fixOnBandTicksCoords(
ticksItem.coord -= bandWidth / 2;
});

const dataExtent = axis.scale.getExtent();
const oldLast = preTicksCoords[ticksLen - 1];
if (oldLast.tick.offInterval) {
preTicksCoords.pop();
if (tickCategoryInterval != null) {
const dataExtent = axis.scale.getExtent();
const oldLast = preTicksCoords[ticksLen - 1];
if (oldLast.tick.offInterval) {
preTicksCoords.pop();
}
preTicksCoords.push({
coord: oldLast.coord + bandWidth,
tick: {value: dataExtent[1] + 1},
});
}
preTicksCoords.push({
coord: oldLast.coord + bandWidth,
tick: {value: dataExtent[1] + 1},
});

return true;
}
Expand Down
7 changes: 4 additions & 3 deletions src/coord/axisTickLabelBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,10 @@ function makeTicksLabelsByCategoryIntervalNumOrCb(
// It is time consuming for large category data.
const isOnInterval = !!categoryInterval(tickObj.value, tickLabel);
tickObj.offInterval = !isOnInterval;
// axis extent min max labels should be always included and the display strategy
// is adopted uniformly later in `AxisBuilder`.
if (!isOnInterval && !isExtentBoundary) {
// Axis extent min max labels should be always included and the display strategy
// is adopted uniformly later in `AxisBuilder`. For ticks, keep strictly to the
// callback result.
if (!isOnInterval && (onlyTick || !isExtentBoundary)) {
return;
}
}
Expand Down
51 changes: 51 additions & 0 deletions test/ut/spec/scale/interval.test.ts

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