Skip to content

Commit

Permalink
fix(axis): fix error when showing tick only
Browse files Browse the repository at this point in the history
Do not call .getBBox() for empty node

Ref naver#3881
  • Loading branch information
netil committed Sep 20, 2024
1 parent 385907e commit d853337
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ChartInternal/Axis/AxisRendererHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export default class AxisRendererHelper {
w: 5.5,
h: 11.5
};
const text = node?.select("text");

!node.empty() && node.select("text")
!text.empty() && text
.text("0")
.call(el => {
try {
Expand Down
6 changes: 3 additions & 3 deletions test/api/export-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ describe("API export", () => {

// pattern for local: preserveFontStyle=true
[
"byuVSgeSACZuGnZIBBJFgAQwUbjZWVoQIAFMi6UoZ1gEhoeHzxORj7",
"gEMwIYvjgilxAsgoYFymZLtEoI4ACaBlzpB5Aqh4u1HAwik2LwOTAFo2",
"n3KPP7RFhvxMH97ZLyZpsgzMpjX2Qk8O3IUePj1WqYqk0kYkwz"
"i2iAoIcLvwVDzzAQUBmuodjmOmu+NeryqrOrq4jsyozKyLzy99vftNVcb343ou",
"JXSOKRvoLXeaeBnwyQ3q5TJIDtEMpaehdeQBLArBlL9P1Ni",
"iDzpkxgBoCd9qkExwC4O8qSCPVk3lyWshNuFqQAdJNm6rb+GVkH2CdOcenYIgj5Cy"
],

// pattern for webdriverio
Expand Down
39 changes: 39 additions & 0 deletions test/internals/axis-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,45 @@ describe("AXIS", function() {
expect(axis.selectAll(".tick line").size()).to.be.equal(0);
});
});

it("set options", () => {
args = {
data: {
columns: [
["data1", 90, 100, 140, 200, 100]
],
type: "bar",
},
axis: {
x: {
tick: {
show: false,
text: {
show: false
}
}
},
y: {
tick: {
show: false,
text: {
show: false
}
}
}
}
};
});

it("should show tick without error", () => {
expect(
chart.config("axis.y.tick.show", true, true)
).to.not.throw;

expect(
chart.internal.$el.axis.y.selectAll(".tick").size() > 0
).to.be.true;
});
});

describe("axis text on 'binary floating point'", () => {
Expand Down

0 comments on commit d853337

Please sign in to comment.