Skip to content

Commit

Permalink
fix(clip): Fix x axis hide on title.bottom
Browse files Browse the repository at this point in the history
Adjust x axis' <clipPath> height to prevent axis being hidden

Fix #3364
  • Loading branch information
netil authored and netil committed Sep 5, 2023
1 parent b0fc214 commit d00052c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ChartInternal/internals/clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ export default {
const isRotated = config.axis_rotated;
const left = Math.max(30, margin.left) - (isRotated ? 0 : 20);

const x = isRotated ? -(1 + left) : -(left - 1);
const y = -Math.max(15, margin.top);
const w = isRotated ? margin.left + 20 : width + 10 + left;

// less than 20 is not enough to show the axis label 'outer' without legend
const h = (isRotated ? (margin.top + height) + 10 : margin.bottom) + 20;

const x = isRotated ? -(1 + left) : -(left - 1);
const y = -Math.max(15, margin.bottom);
const w = isRotated ? margin.left + 20 : width + 10 + left;

node
.attr("x", x)
.attr("y", y)
Expand Down
1 change: 1 addition & 0 deletions src/config/Options/axis/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default {
* - **log** type:
* - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
* - x axis min value should be >= 0.
* - for 'category' type, `data.xs` option isn't supported.
*
* @name axis鈥鈥ype
* @memberof Options
Expand Down
8 changes: 8 additions & 0 deletions test/internals/title-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ describe("TITLE", () => {
args.title.padding.top + height + args.title.padding.bottom
);
});

it("check x axis <clipPath>'s height", () => {
const {internal: {state}, $: {svg}} = chart;
const xClipPath = svg.select(`#${state.clip.idXAxis} rect`).node();

expect(Math.abs(+xClipPath.getAttribute("y"))).to.be.below(100);

});
});

describe("and position left", () => {
Expand Down

0 comments on commit d00052c

Please sign in to comment.