Skip to content

Commit e49fc41

Browse files
committed
make room for push options - quick proto to push left and right
1 parent e4a13b3 commit e49fc41

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/plots/cartesian/axes.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,7 @@ axes.drawLabels = function(gd, ax, opts) {
30583058
if(!ticklabeloverflow || ticklabeloverflow === 'allow') return;
30593059

30603060
var hideOverflow = ticklabeloverflow.indexOf('hide') !== -1;
3061+
var pushOverflow = ticklabeloverflow.indexOf('push') !== -1;
30613062

30623063
var isX = ax._id.charAt(0) === 'x';
30633064
// div positions
@@ -3087,18 +3088,22 @@ axes.drawLabels = function(gd, ax, opts) {
30873088

30883089
if(mathjaxGroup.empty()) {
30893090
var bb = Drawing.bBox(thisLabel.node());
3090-
var adjust = false;
3091+
var adjust = '';
30913092
if(isX) {
3092-
if(bb.right > max) adjust = true;
3093-
else if(bb.left < min) adjust = true;
3093+
if(bb.right > max) adjust += 'right';
3094+
else if(bb.left < min) adjust += 'left';
30943095
} else {
3095-
if(bb.bottom > max) adjust = true;
3096-
else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) adjust = true;
3096+
if(bb.bottom > max) adjust += 'top';
3097+
else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) adjust += 'bottom';
30973098
}
30983099

30993100
var t = thisLabel.select('text');
31003101
if(adjust) {
31013102
if(hideOverflow) t.style('opacity', 0); // hidden
3103+
else if(pushOverflow) {
3104+
if(adjust.indexOf('left') !== -1) t.attr('text-anchor', 'start');
3105+
if(adjust.indexOf('right') !== -1) t.attr('text-anchor', 'end');
3106+
}
31023107
} else {
31033108
t.style('opacity', 1); // visible
31043109

0 commit comments

Comments
 (0)