Skip to content

Commit bae37be

Browse files
committed
move 'maxFontSize' and 'autoangle' to fixLabelOverlaps scope
... as they are not used in the Axes.drawLabels scope
1 parent b05f8fb commit bae37be

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/plots/cartesian/axes.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -2191,8 +2191,6 @@ axes.drawLabels = function(gd, ax, opts) {
21912191
var tickLabels = opts.layer.selectAll('g.' + cls)
21922192
.data(ax.showticklabels ? vals : [], makeDataFn(ax));
21932193

2194-
var maxFontSize = 0;
2195-
var autoangle = 0;
21962194
var labelsReady = [];
21972195

21982196
tickLabels.enter().append('g')
@@ -2227,10 +2225,6 @@ axes.drawLabels = function(gd, ax, opts) {
22272225

22282226
tickLabels.exit().remove();
22292227

2230-
tickLabels.each(function(d) {
2231-
maxFontSize = Math.max(maxFontSize, d.fontSize);
2232-
});
2233-
22342228
ax._tickLabels = tickLabels;
22352229

22362230
// TODO ??
@@ -2313,9 +2307,10 @@ axes.drawLabels = function(gd, ax, opts) {
23132307
// check for auto-angling if x labels overlap
23142308
// don't auto-angle at all for log axes with
23152309
// base and digit format
2316-
if(axLetter === 'x' && !isNumeric(ax.tickangle) &&
2310+
if(vals.length && axLetter === 'x' && !isNumeric(ax.tickangle) &&
23172311
(ax.type !== 'log' || String(ax.dtick).charAt(0) !== 'D')
23182312
) {
2313+
var maxFontSize = 0;
23192314
var lbbArray = [];
23202315
var i;
23212316

@@ -2324,6 +2319,8 @@ axes.drawLabels = function(gd, ax, opts) {
23242319
var thisLabel = s.select('.text-math-group');
23252320
if(thisLabel.empty()) thisLabel = s.select('text');
23262321

2322+
maxFontSize = Math.max(maxFontSize, d.fontSize);
2323+
23272324
var x = ax.l2p(d.x);
23282325
var bb = Drawing.bBox(thisLabel.node());
23292326

@@ -2339,6 +2336,7 @@ axes.drawLabels = function(gd, ax, opts) {
23392336
});
23402337
});
23412338

2339+
var autoangle = 0;
23422340
for(i = 0; i < lbbArray.length - 1; i++) {
23432341
if(Lib.bBoxIntersect(lbbArray[i], lbbArray[i + 1])) {
23442342
// any overlap at all - set 30 degrees

0 commit comments

Comments
 (0)