Skip to content

Commit d931a9e

Browse files
committed
lint: bar setPositions comments + spaces
1 parent d279716 commit d931a9e

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/traces/bar/set_positions.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,11 @@ module.exports = function setPositions(gd, plotinfo) {
148148
if(!isNumeric(ti[j].s)) continue;
149149

150150
sv = Math.round(ti[j].p / sumround);
151-
// store the negative sum value for p at the same key, with sign flipped
152-
if(relative && ti[j].s < 0) sv = '-' + sv; // use string to ensure -0 !== 0
151+
152+
// store the negative sum value for p at the same key,
153+
// with sign flipped using string to ensure -0 !== 0.
154+
if(relative && ti[j].s < 0) sv = '-' + sv;
155+
153156
var previousSum = sums[sv] || 0;
154157
if(stack || relative) ti[j].b = previousSum;
155158
barEnd = ti[j].b + ti[j].s;
@@ -167,20 +170,29 @@ module.exports = function setPositions(gd, plotinfo) {
167170
}
168171

169172
if(norm) {
170-
padded = false;
171173
var top = norm === 'fraction' ? 1 : 100,
172174
relAndNegative = false,
173175
tiny = top / 1e9; // in case of rounding error in sum
176+
177+
padded = false;
174178
sMin = 0;
175179
sMax = stack ? top : 0;
180+
176181
for(i = 0; i < bl.length; i++) { // trace index
177182
ti = gd.calcdata[bl[i]];
183+
178184
for(j = 0; j < ti.length; j++) {
179-
relAndNegative = relative && ti[j].s < 0;
185+
relAndNegative = (relative && ti[j].s < 0);
186+
180187
sv = Math.round(ti[j].p / sumround);
181-
if(relAndNegative) sv = '-' + sv; // locate negative sum amount for this p val
188+
189+
// locate negative sum amount for this p val
190+
if(relAndNegative) sv = '-' + sv;
191+
182192
scale = top / sums[sv];
183-
if(relAndNegative) scale *= -1; // preserve sign if negative
193+
194+
// preserve sign if negative
195+
if(relAndNegative) scale *= -1;
184196
ti[j].b *= scale;
185197
ti[j].s *= scale;
186198
barEnd = ti[j].b + ti[j].s;

0 commit comments

Comments
 (0)