Skip to content

Commit 80dedea

Browse files
committed
Revert "Fix backwards-compatibility"
This reverts commit 9473029.
1 parent cdae996 commit 80dedea

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

src/plots/cartesian/axes.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,9 +3480,8 @@ 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 ?
3484-
ax.autotickangles.map(function(degrees) { return degrees * Math.PI / 180; }) :
3485-
undefined;
3483+
var autoTickAnglesRadians =
3484+
ax.autotickangles.map(function(degrees) { return degrees * Math.PI / 180; });
34863485
var prevAngle = (ax._prevTickAngles || {})[cls];
34873486

34883487
var tickLabels = opts.layer.selectAll('g.' + cls)
@@ -3785,26 +3784,23 @@ axes.drawLabels = function(gd, ax, opts) {
37853784
var pad = !isAligned ? 0 :
37863785
(ax.tickwidth || 0) + 2 * TEXTPAD;
37873786

3788-
// old behavior for backwards-compatibility
3789-
var newAngle = ((tickSpacing < maxFontSize * 2.5) || ax.type === 'multicategory' || ax._name === 'realaxis') ? 90 : 30;
37903787
// autotickangles
3791-
if(autoTickAnglesRadians !== undefined) {
3792-
var adjacent = tickSpacing;
3793-
var opposite = maxFontSize * 1.25 * maxLines;
3794-
var hypotenuse = Math.sqrt(Math.pow(adjacent, 2) + Math.pow(opposite, 2));
3795-
var maxCos = adjacent / hypotenuse;
3796-
var angleRadians = autoTickAnglesRadians.find(function(angle) { return Math.abs(Math.cos(angle)) <= maxCos; });
3797-
if(angleRadians === undefined) {
3798-
// no angle with smaller cosine than maxCos, just pick the angle with smallest cosine
3799-
angleRadians = autoTickAnglesRadians.reduce(
3800-
function(currentMax, nextAngle) {
3801-
return Math.abs(Math.cos(currentMax)) < Math.abs(Math.cos(nextAngle)) ? currentMax : nextAngle;
3802-
}
3803-
, autoTickAnglesRadians[0]
3804-
);
3805-
}
3806-
newAngle = angleRadians * (180 / Math.PI /* to degrees */);
3788+
var adjacent = tickSpacing;
3789+
var opposite = maxFontSize * 1.25 * maxLines;
3790+
var hypotenuse = Math.sqrt(Math.pow(adjacent, 2) + Math.pow(opposite, 2));
3791+
var maxCos = adjacent / hypotenuse;
3792+
var angleRadians = autoTickAnglesRadians.find(function(angle) { return Math.abs(Math.cos(angle)) <= maxCos; });
3793+
if(angleRadians === undefined) {
3794+
// no angle with smaller cosine than maxCos, just pick the angle with smallest cosine
3795+
angleRadians = autoTickAnglesRadians.reduce(
3796+
function(currentMax, nextAngle) {
3797+
return Math.abs(Math.cos(currentMax)) < Math.abs(Math.cos(nextAngle)) ? currentMax : nextAngle;
3798+
}
3799+
, autoTickAnglesRadians[0]
3800+
);
38073801
}
3802+
var newAngle = angleRadians * (180 / Math.PI /* to degrees */);
3803+
38083804
for(i = 0; i < lbbArray.length - 1; i++) {
38093805
if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1], pad)) {
38103806
autoangle = newAngle;

src/plots/cartesian/layout_attributes.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,12 @@ module.exports = {
815815
items: {
816816
valType: 'angle'
817817
},
818-
dflt: null,
818+
dflt: [30, 90],
819819
editType: 'ticks',
820820
description: [
821821
'When `tickangle` is set to *auto*, it will be set to the first',
822822
'angle in this array that is large enough to prevent label',
823-
'overlap. If undefined, tickangle *auto* will instead choose',
824-
'between 30 and 90 degrees.'
823+
'overlap.'
825824
].join(' ')
826825
},
827826
tickprefix: {

test/plot-schema.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10700,8 +10700,11 @@
1070010700
"role": "object"
1070110701
},
1070210702
"autotickangles": {
10703-
"description": "When `tickangle` is set to *auto*, it will be set to the first angle in this array that is large enough to prevent label overlap. If undefined, tickangle *auto* will instead choose between 30 and 90 degrees.",
10704-
"dflt": null,
10703+
"description": "When `tickangle` is set to *auto*, it will be set to the first angle in this array that is large enough to prevent label overlap.",
10704+
"dflt": [
10705+
30,
10706+
90
10707+
],
1070510708
"editType": "ticks",
1070610709
"freeLength": true,
1070710710
"items": {
@@ -12050,8 +12053,11 @@
1205012053
"valType": "boolean"
1205112054
},
1205212055
"autotickangles": {
12053-
"description": "When `tickangle` is set to *auto*, it will be set to the first angle in this array that is large enough to prevent label overlap. If undefined, tickangle *auto* will instead choose between 30 and 90 degrees.",
12054-
"dflt": null,
12056+
"description": "When `tickangle` is set to *auto*, it will be set to the first angle in this array that is large enough to prevent label overlap.",
12057+
"dflt": [
12058+
30,
12059+
90
12060+
],
1205512061
"editType": "ticks",
1205612062
"freeLength": true,
1205712063
"items": {

0 commit comments

Comments
 (0)