Skip to content

Commit

Permalink
fix(axis): Fix x Axis tick height calculation
Browse files Browse the repository at this point in the history
Update condition determining x Axis tick is rotated to consider
absolute number(weather positive or negative) value.

Ref naver#3643
  • Loading branch information
netil committed Feb 14, 2024
1 parent e887baf commit e70f235
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ChartInternal/internals/size.axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {

const maxtickSize = $$.axis.getMaxTickSize(id);

const isXAxisTickRotated = config.axis_x_tick_rotate > 0 && (
const isXAxisTickRotated = Math.abs(config.axis_x_tick_rotate) > 0 && (
!config.axis_x_tick_autorotate || $$.needToRotateXAxisTickTexts()
);

Expand Down
12 changes: 12 additions & 0 deletions test/internals/axis-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,18 @@ describe("AXIS", function() {
expect(height).to.be.above(67);
expect(height).to.be.below(80);
});

it("set options: axis.x.tick.multiline=false", () => {
args.axis.x.tick.multiline = false;
});

it("x Axis shouldn't be overlapped with the legend", () => {
const {legend, main} = chart.$;
const legendRect = legend.node().getBoundingClientRect();
const xAxisRect = main.selectAll(`.${$AXIS.axisX}`).node().getBoundingClientRect();

expect(legendRect.top > xAxisRect.bottom).to.be.true;
});
});
});

Expand Down

0 comments on commit e70f235

Please sign in to comment.