Skip to content

Commit

Permalink
refactor(bar): handle clip-path updates
Browse files Browse the repository at this point in the history
clip-path style should be updated according the data toggles

Ref #3903
  • Loading branch information
netil committed Oct 23, 2024
1 parent 91b5dca commit 35683ea
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ChartInternal/shape/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ export default {
}
}

d.clipPath = `inset(${clipPath})`;
if (clipPath) {
d.clipPath = `inset(${clipPath})`;
}
}

// path string data shouldn't be containing new line chars
Expand Down
48 changes: 48 additions & 0 deletions test/shape/bar-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,54 @@ describe("SHAPE BAR", () => {
}
});
});

it("set options", () => {
args = {
data: {
columns: [
["data1", -80],
["data2", 80],
["data3", -120]
],
type: "bar",
groups: [
[
"data1",
"data2"
]
],
order: "desc"
},
bar: {
radius: {
ratio: 0.5
}
},
transition: {
duration: 0
}
};
});

it("clip-path style should be updated", () => {
// when
chart.hide("data3");

chart.$.bar.bars.each(function(d) {
if (d.id !== "data3") {
expect(this.style.clipPath.length > 0).to.be.true;
} else {
expect(this.style.clipPath).to.be.equal("");
}
});

// when
chart.show("data3");

chart.$.bar.bars.each(function(d) {
expect(this.style.clipPath).to.be.equal("");
});
})
});

describe("bar linear gradient", () => {
Expand Down

0 comments on commit 35683ea

Please sign in to comment.