diff --git a/src/traces/bar/set_positions.js b/src/traces/bar/set_positions.js index 14daefccfe4..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; + 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;