Skip to content

Commit 0cc638a

Browse files
authored
refactor(bar): handle clip-path updates (#3905)
clip-path style should be updated according the data toggles Ref #3903
1 parent 91b5dca commit 0cc638a

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/ChartInternal/shape/bar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ export default {
230230
}
231231
}
232232

233-
d.clipPath = `inset(${clipPath})`;
233+
if (clipPath) {
234+
d.clipPath = `inset(${clipPath})`;
235+
}
234236
}
235237

236238
// path string data shouldn't be containing new line chars

test/shape/bar-spec.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,54 @@ describe("SHAPE BAR", () => {
11491149
}
11501150
});
11511151
});
1152+
1153+
it("set options", () => {
1154+
args = {
1155+
data: {
1156+
columns: [
1157+
["data1", -80],
1158+
["data2", 80],
1159+
["data3", -120]
1160+
],
1161+
type: "bar",
1162+
groups: [
1163+
[
1164+
"data1",
1165+
"data2"
1166+
]
1167+
],
1168+
order: "desc"
1169+
},
1170+
bar: {
1171+
radius: {
1172+
ratio: 0.5
1173+
}
1174+
},
1175+
transition: {
1176+
duration: 0
1177+
}
1178+
};
1179+
});
1180+
1181+
it("clip-path style should be updated", () => {
1182+
// when
1183+
chart.hide("data3");
1184+
1185+
chart.$.bar.bars.each(function(d) {
1186+
if (d.id !== "data3") {
1187+
expect(this.style.clipPath.length > 0).to.be.true;
1188+
} else {
1189+
expect(this.style.clipPath).to.be.equal("");
1190+
}
1191+
});
1192+
1193+
// when
1194+
chart.show("data3");
1195+
1196+
chart.$.bar.bars.each(function(d) {
1197+
expect(this.style.clipPath).to.be.equal("");
1198+
});
1199+
})
11521200
});
11531201

11541202
describe("bar linear gradient", () => {

0 commit comments

Comments
 (0)