Skip to content

Commit 6a84220

Browse files
committed
make bar transform functions on par with pie - rotation > rotate
1 parent 404611d commit 6a84220

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/traces/bar/plot.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1, opts) {
361361
textSelection.attr('transform', transform);
362362
}
363363

364-
function getRotationFromAngle(angle) {
364+
function getRotateFromAngle(angle) {
365365
return (angle === 'auto') ? 0 : angle;
366366
}
367367

@@ -402,9 +402,9 @@ function toMoveInsideBar(x0, x1, y0, y1, textBB, opts) {
402402
lx = tmp;
403403
}
404404

405-
var rotation = getRotationFromAngle(angle);
406-
var absSin = Math.abs(Math.sin(Math.PI / 180 * rotation));
407-
var absCos = Math.abs(Math.cos(Math.PI / 180 * rotation));
405+
var rotate = getRotateFromAngle(angle);
406+
var absSin = Math.abs(Math.sin(Math.PI / 180 * rotate));
407+
var absCos = Math.abs(Math.cos(Math.PI / 180 * rotate));
408408

409409
// compute and apply text padding
410410
var dx = Math.max(lx * absCos, ly * absSin);
@@ -438,15 +438,15 @@ function toMoveInsideBar(x0, x1, y0, y1, textBB, opts) {
438438
var textY = (textBB.top + textBB.bottom) / 2;
439439

440440
// lastly apply auto rotation
441-
if(isAutoRotated) rotation += 90;
441+
if(isAutoRotated) rotate += 90;
442442

443443
return {
444444
textX: textX,
445445
textY: textY,
446446
targetX: targetX,
447447
targetY: targetY,
448448
scale: scale,
449-
rotation: rotation
449+
rotate: rotate
450450
};
451451
}
452452

@@ -469,17 +469,17 @@ function toMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
469469
textpad = (lx > 2 * TEXTPAD) ? TEXTPAD : 0;
470470
}
471471

472-
// compute rotation and scale
472+
// compute rotate and scale
473473
var scale = 1;
474474
if(constrained) {
475475
scale = (isHorizontal) ?
476476
Math.min(1, ly / textHeight) :
477477
Math.min(1, lx / textWidth);
478478
}
479479

480-
var rotation = getRotationFromAngle(angle);
481-
var absSin = Math.abs(Math.sin(Math.PI / 180 * rotation));
482-
var absCos = Math.abs(Math.cos(Math.PI / 180 * rotation));
480+
var rotate = getRotateFromAngle(angle);
481+
var absSin = Math.abs(Math.sin(Math.PI / 180 * rotate));
482+
var absCos = Math.abs(Math.cos(Math.PI / 180 * rotate));
483483

484484
// compute text and target positions
485485
var targetWidth = scale * (isHorizontal ? textHeight : textWidth);
@@ -504,7 +504,7 @@ function toMoveOutsideBar(x0, x1, y0, y1, textBB, opts) {
504504
targetX: targetX,
505505
targetY: targetY,
506506
scale: scale,
507-
rotation: rotation
507+
rotate: rotate
508508
};
509509
}
510510

@@ -514,7 +514,7 @@ function getTransform(opts) {
514514
var targetX = opts.targetX;
515515
var targetY = opts.targetY;
516516
var scale = opts.scale;
517-
var rotation = opts.rotation;
517+
var rotate = opts.rotate;
518518

519519
var transformScale;
520520
var transformRotate;
@@ -526,8 +526,8 @@ function getTransform(opts) {
526526
transformScale = '';
527527
}
528528

529-
transformRotate = (rotation) ?
530-
'rotate(' + rotation + ' ' + textX + ' ' + textY + ') ' : '';
529+
transformRotate = (rotate) ?
530+
'rotate(' + rotate + ' ' + textX + ' ' + textY + ') ' : '';
531531

532532
// Note that scaling also affects the center of the text box
533533
var translateX = (targetX - scale * textX);

0 commit comments

Comments
 (0)