From 9699abfdb1c8eb88a7906c5fee11010ab9a1e47a Mon Sep 17 00:00:00 2001 From: keeganmccallum Date: Thu, 23 Jun 2016 18:23:39 -0400 Subject: [PATCH 1/2] fix issue with bar releative mode when first bucket is 0 or string --- src/traces/bar/set_positions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traces/bar/set_positions.js b/src/traces/bar/set_positions.js index 14daefccfe4..18c98a35d76 100644 --- a/src/traces/bar/set_positions.js +++ b/src/traces/bar/set_positions.js @@ -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; From 660cbb8a66ce48bd58e47a068868965831dc5b4b Mon Sep 17 00:00:00 2001 From: keeganmccallum Date: Thu, 23 Jun 2016 18:40:47 -0400 Subject: [PATCH 2/2] fix formatting --- src/traces/bar/set_positions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/traces/bar/set_positions.js b/src/traces/bar/set_positions.js index 18c98a35d76..6b80bec85c9 100644 --- a/src/traces/bar/set_positions.js +++ b/src/traces/bar/set_positions.js @@ -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; // use string to ensure -0 !== 0 + 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; @@ -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;