Skip to content

Commit 7d8e607

Browse files
committed
- only coerce autotickangles for x axes with auto tickangle
- start with the first autotickangle entry, not 0 - move radian calculation closer to its use
1 parent f544c2a commit 7d8e607

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Diff for: src/plots/cartesian/axes.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -3472,16 +3472,13 @@ axes.drawLabels = function(gd, ax, opts) {
34723472

34733473
var fullLayout = gd._fullLayout;
34743474
var axId = ax._id;
3475-
var axLetter = axId.charAt(0);
34763475
var cls = opts.cls || axId + 'tick';
34773476

34783477
var vals = opts.vals.filter(function(d) { return d.text; });
34793478

34803479
var labelFns = opts.labelFns;
34813480
var tickAngle = opts.secondary ? 0 : ax.tickangle;
34823481

3483-
var autoTickAnglesRadians = (ax.autotickangles || [0, 30, 90])
3484-
.map(function(degrees) { return degrees * Math.PI / 180; });
34853482
var prevAngle = (ax._prevTickAngles || {})[cls];
34863483

34873484
var tickLabels = opts.layer.selectAll('g.' + cls)
@@ -3722,10 +3719,10 @@ axes.drawLabels = function(gd, ax, opts) {
37223719
// check for auto-angling if x labels overlap
37233720
// don't auto-angle at all for log axes with
37243721
// base and digit format
3725-
if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) &&
3722+
if(vals.length && ax.autotickangles &&
37263723
(ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')
37273724
) {
3728-
autoangle = 0;
3725+
autoangle = ax.autotickangles[0];
37293726

37303727
var maxFontSize = 0;
37313728
var lbbArray = [];
@@ -3789,7 +3786,12 @@ axes.drawLabels = function(gd, ax, opts) {
37893786
var opposite = maxFontSize * 1.25 * maxLines;
37903787
var hypotenuse = Math.sqrt(Math.pow(adjacent, 2) + Math.pow(opposite, 2));
37913788
var maxCos = adjacent / hypotenuse;
3792-
var angleRadians = autoTickAnglesRadians.find(function(angle) { return Math.abs(Math.cos(angle)) <= maxCos; });
3789+
var autoTickAnglesRadians = ax.autotickangles.map(
3790+
function(degrees) { return degrees * Math.PI / 180; }
3791+
);
3792+
var angleRadians = autoTickAnglesRadians.find(
3793+
function(angle) { return Math.abs(Math.cos(angle)) <= maxCos; }
3794+
);
37933795
if(angleRadians === undefined) {
37943796
// no angle with smaller cosine than maxCos, just pick the angle with smallest cosine
37953797
angleRadians = autoTickAnglesRadians.reduce(

Diff for: src/plots/cartesian/layout_defaults.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
242242
visibleDflt: visibleDflt,
243243
reverseDflt: reverseDflt,
244244
autotypenumbersDflt: autotypenumbersDflt,
245-
splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[axId]
245+
splomStash: ((layoutOut._splomAxes || {})[axLetter] || {})[axId],
246+
noAutotickangles: axLetter === 'y'
246247
};
247248

248249
coerce('uirevision', layoutOut.uirevision);

Diff for: src/plots/cartesian/tick_label_defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
4141
}
4242

4343
if(!options.noAng) {
44-
coerce('tickangle');
45-
if(!options.noAutotickangles) {
44+
var tickAngle = coerce('tickangle');
45+
if(!options.noAutotickangles && tickAngle === 'auto') {
4646
coerce('autotickangles');
4747
}
4848
}

0 commit comments

Comments
 (0)