Skip to content

Commit eb3c456

Browse files
committed
autotickangles: consider number of lines when calculating min angle
1 parent 9170f25 commit eb3c456

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/plots/cartesian/axes.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,13 +3728,14 @@ axes.drawLabels = function(gd, ax, opts) {
37283728
var maxFontSize = 0;
37293729
var lbbArray = [];
37303730
var i;
3731-
3731+
var maxLines = 1;
37323732
tickLabels.each(function(d) {
37333733
maxFontSize = Math.max(maxFontSize, d.fontSize);
37343734

37353735
var x = ax.l2p(d.x);
37363736
var thisLabel = selectTickLabel(this);
37373737
var bb = Drawing.bBox(thisLabel.node());
3738+
maxLines = Math.max(maxLines, svgTextUtils.lineCount(thisLabel));
37383739

37393740
lbbArray.push({
37403741
// ignore about y, just deal with x overlaps
@@ -3782,7 +3783,7 @@ axes.drawLabels = function(gd, ax, opts) {
37823783
(ax.tickwidth || 0) + 2 * TEXTPAD;
37833784

37843785
const adjacent = tickSpacing;
3785-
const opposite = maxFontSize * 1.25;
3786+
const opposite = maxFontSize * 1.25 * maxLines;
37863787
const hypotenuse = Math.sqrt(Math.pow(adjacent, 2) + Math.pow(opposite, 2));
37873788
// sin(angle) = opposite / hypotenuse
37883789
const minAngle = Math.asin(opposite / hypotenuse) * (180 / Math.PI /* to degrees */);

0 commit comments

Comments
 (0)