Skip to content

Commit 1628b5c

Browse files
committed
avoid using Math.sign
1 parent 9dd0896 commit 1628b5c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/traces/bar/plot.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function getKeyFunc(trace) {
3434
}
3535
}
3636

37+
function sign(v) {
38+
return (v > 0) - (v < 0);}
39+
3740
function dirSign(a, b) {
3841
return (a < b) ? 1 : -1;
3942
}
@@ -277,7 +280,7 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
277280
// Bar has cornerradius, and nonzero size
278281
// Check amount of 'overhead' (bars stacked above this one)
279282
// to see whether we need to round or not
280-
var refPoint = Math.sign(di.s0) === 0 || Math.sign(di.s) === Math.sign(di.s0) ? di.s1 : di.s0;
283+
var refPoint = sign(di.s0) === 0 || sign(di.s) === sign(di.s0) ? di.s1 : di.s0;
281284
var overhead = fixpx(!di.hasB ? Math.abs(c2p(outerBound, true) - c2p(refPoint, true)) : 0);
282285
if(overhead < r) {
283286
// Calculate parameters for rounded corners

0 commit comments

Comments
 (0)