Skip to content

Commit

Permalink
refactor(clipPath): fix side-effect caused by #3367 (#3409)
Browse files Browse the repository at this point in the history
Make x Axis clipPath y coordinate to be fixed

Ref #3367
  • Loading branch information
netil authored Sep 7, 2023
1 parent 569c21c commit 990fcf7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/ChartInternal/internals/clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ export default {
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)
.attr("y", -2)
.attr("width", w)
.attr("height", h);
},
Expand Down
34 changes: 34 additions & 0 deletions test/internals/axis-x-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,39 @@ describe("X AXIS", function() {
expect(lines.attr("d")).to.be.equal(initialPath);
});
});

describe("", () => {
before(() => {
args = {
data: {
x: "x",
columns: [
["x", "www.somesitename1.com", "www.somesitename2.com", "www.somesitename3.com", "www.somesitename4.com", "www.somesitename5.com", "www.somesitename6.com", "www.somesitename7.com", "www.somesitename8.com", "www.somesitename9.com", "www.somesitename10.com", "www.somesitename11.com", "www.somesitename12.com"],
["pv", 90, 100, 140, 200, 100, 400, 90, 100, 140, 200, 100, 400]
],
type: "bar"
},
axis: {
x: {
type: "category",
tick: {
rotate: 75,
multiline: false,
tooltip: true
},
height: 130
}
}
};
});

it("should clipPath for x axis size defined as x Axis' dimension.", () => {
const clipRect = chart.internal.$el.defs.select("[id$=xaxis] rect");
const axisRect = chart.$.main.select(`.${$AXIS.axisX}`).node().getBoundingClientRect();

expect(axisRect.height).to.be.below(+clipRect.attr("height"));
expect(+clipRect.attr("y") > -50).to.be.be.ok;
});
});
});
});

0 comments on commit 990fcf7

Please sign in to comment.