Skip to content

fix issue with bar relative mode when first bucket is 0 or string #687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/traces/bar/set_positions.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ module.exports = function setPositions(gd, plotinfo) {
for(j = 0; j < ti.length; j++) {
sv = Math.round(ti[j].p / sumround);
// store the negative sum value for p at the same key, with sign flipped
if(relative && ti[j].s < 0) sv = -sv;
if(relative && ti[j].s < 0) sv = '-' + sv; // use string to ensure -0 !== 0
var previousSum = sums[sv] || 0;
if(stack || relative) ti[j].b = previousSum;
barEnd = ti[j].b + ti[j].s;
Expand Down Expand Up @@ -173,7 +173,7 @@ module.exports = function setPositions(gd, plotinfo) {
for(j = 0; j < ti.length; j++) {
relAndNegative = relative && ti[j].s < 0;
sv = Math.round(ti[j].p / sumround);
if(relAndNegative) sv = -sv; // locate negative sum amount for this p val
if(relAndNegative) sv = '-' + sv; // locate negative sum amount for this p val
scale = top / sums[sv];
if(relAndNegative) scale *= -1; // preserve sign if negative
ti[j].b *= scale;
Expand Down