Skip to content

Commit

Permalink
fix(arc): Fix to generate arc when data is zero
Browse files Browse the repository at this point in the history
Update condition when generate arc path value.

Fix #935
  • Loading branch information
netil authored Jun 17, 2019
1 parent 4b95d82 commit 04a4dd8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions spec/shape/shape.arc-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,44 @@ describe("SHAPE ARC", () => {
checkMultiline(chart.$.arc);
});
});

describe("check for data loading", () => {
it("Interaction of chart when initialized with 0 and .load()", done => {
const chart = util.generate({
data: {
columns: [
["data1", 0],
["data2", 0],
],
type: "pie",
}
});

setTimeout(function() {
chart.load({
columns: [
["data1", 3],
["data2", 6],
],
done: () => {
const legend = chart.$.legend.select(`.${CLASS.legendItem}-data2`).node();

util.fireEvent(legend, "mouseover");
util.fireEvent(legend, "mouseout");

setTimeout(() => {
chart.$.arc.selectAll("path").each(function() {
const rect = this.getBoundingClientRect();

expect(this.getAttribute("d")).to.not.be.equal("M 0 0");
expect(rect.width > 0 && rect.height > 0).to.be.true;
});

done();
}, 1000);
}
});
}, 1000);
});
});
});
2 changes: 1 addition & 1 deletion src/shape/arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ extend(ChartInternal.prototype, {
const newArc = (d, withoutUpdate) => {
let path = "M 0 0";

if ("value" in d ? d.value > 0 : d.data) {
if (d.value || d.data) {
if (!isNumber(ir)) {
arc = arc.innerRadius($$.getInnerRadius(d));
}
Expand Down

0 comments on commit 04a4dd8

Please sign in to comment.