Skip to content

Commit fdd6d03

Browse files
committed
small cleanup and add comments
1 parent b137b25 commit fdd6d03

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/traces/bar/plot.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ function getKeyFunc(trace) {
3434
}
3535
}
3636

37+
// Returns -1 if v < 0, 1 if v > 0, and 0 if v == 0
3738
function sign(v) {
3839
return (v > 0) - (v < 0);
3940
}
4041

42+
// Returns 1 if a < b and -1 otherwise
43+
// (For the purposes of this module we don't care about the case where a == b)
4144
function dirSign(a, b) {
4245
return (a < b) ? 1 : -1;
4346
}
@@ -251,14 +254,15 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback)
251254

252255
// Calculate corner radius of bar in pixels
253256
function calcCornerRadius(crValue, crForm) {
257+
if(!crValue) return 0;
258+
254259
var barWidth = isHorizontal ? Math.abs(y1 - y0) : Math.abs(x1 - x0);
255260
var barLength = isHorizontal ? Math.abs(x1 - x0) : Math.abs(y1 - y0);
256261
var stackedBarTotalLength = fixpx(Math.abs(c2p(outerBound, true) - c2p(0, true)));
257262
var maxRadius = di.hasB ? Math.min(barWidth / 2, barLength / 2) : Math.min(barWidth / 2, stackedBarTotalLength);
258263
var crPx;
259-
if(!crValue) {
260-
return 0;
261-
} else if(crForm === '%') {
264+
265+
if(crForm === '%') {
262266
// If radius is given as a % string, convert to number of pixels
263267
var crPercent = Math.min(50, crValue);
264268
crPx = barWidth * (crPercent / 100);

0 commit comments

Comments
 (0)