Skip to content

Commit

Permalink
fix(bar): Fix bar position on width option
Browse files Browse the repository at this point in the history
Fix incorrect bar width total sum.
Side-effect caused by #720

Fix #832
  • Loading branch information
netil committed Apr 10, 2019
1 parent ebeb30f commit 0883588
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
33 changes: 33 additions & 0 deletions spec/shape/shape.bar-spec.js
Expand Up @@ -413,6 +413,39 @@ describe("SHAPE BAR", () => {
});
});

describe("bar position", () => {
before(() => {
args = {
data: {
columns: [
["data1", 378, 200],
["data2", 130, 100]
],
types: {
data1: "bar",
data2: "line"
}
},
bar: {
width: {
ratio: 0.5
}
}
};
});

it("check for the correct bar width & position", () => {
const expectedPath = [
"M75.25,426V39.636363636363626 H224.75 V426z",
"M374.25,426V221.5747955747956 H523.75 V426z"
];

chart.$.bar.bars.each(function(d, i) {
expect(this.getAttribute("d")).to.be.equal(expectedPath[i]);
});
});
});

describe("bar sensitivity", () => {
before(() => {
args = {
Expand Down
3 changes: 1 addition & 2 deletions src/shape/bar.js
Expand Up @@ -92,9 +92,8 @@ extend(ChartInternal.prototype, {
$$.filterTargetsToShow($$.data.targets).forEach(v => {
if (config.bar_width[v.id]) {
result[v.id] = getWidth(v.id);
result.total.push(result[v.id] || result.width);
}

result.total.push(result[v.id] || result.width);
});
}

Expand Down

0 comments on commit 0883588

Please sign in to comment.