8000 - only coerce autotickangles for x axes with auto tickangle · plotly/plotly.js@39bfdff · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 39bfdff

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 39bfdff

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/plots/cartesian/axes.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,8 +3480,6 @@ axes.drawLabels = function(gd, ax, opts) {
34803480
var labelFns = opts.labelFns;
34813481
var tickAngle = opts.secondary ? 0 : ax.tickangle;
34823482

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

34873485
var tickLabels = opts.layer.selectAll('g.' + cls)
@@ -3722,10 +3720,10 @@ axes.drawLabels = function(gd, ax, opts) {
37223720
// check for auto-angling if x labels overlap
37233721
// don't auto-angle at all for log axes with
37243722
// base and digit format
3725-
if(vals.length && axLetter === 'x' && !isNumeric(tickAngle) &&
3723+
if(vals.length && ax.autotickangles &&
37263724
(ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')
37273725
) {
3728-
autoangle = 0;
3726+
autoangle = ax.autotickangles[0];
37293727

37303728
var maxFontSize = 0;
37313729
var lbbArray = [];
@@ -3789,7 +3787,12 @@ axes.drawLabels = function(gd, ax, opts) {
37893787
var opposite = maxFontSize * 1.25 * maxLines;
37903788
var hypotenuse = Math.sqrt(Math.pow(adjacent, 2) + Math.pow(opposite, 2));
37913789
var maxCos = adjacent / hypotenuse;
3792-
var angleRadians = autoTickAnglesRadians.find(function(angle) { return Math.abs(Math.cos(angle)) <= maxCos; });
3790+
var autoTickAnglesRadians = ax.autotickangles.map(
3791+
function(degrees) { return degrees * Math.PI / 180; }
3792+
);
3793+
var angleRadians = autoTickAnglesRadians.find(
3794+
function(angle) { return Math.abs(Math.cos(angle)) <= maxCos; }
3795+
);
37933796
if(angleRadians === undefined) {
37943797
// no angle with smaller cosine than maxCos, just pick the angle with smallest cosine
37953798
angleRadians = autoTickAnglesRadians.reduce(

src/plots/cartesian/layout_defaults.js

Lines changed: 2 additions & 1 deletion
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);

src/plots/cartesian/tick_label_defaults.js

Lines changed: 2 additions & 2 deletions
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)
0