Skip to content

Commit 360d895

Browse files
committed
Add x boundaries for ticksarray
1 parent 9069e34 commit 360d895

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/plots/cartesian/axes.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,10 +1293,7 @@ function arrayTicks(ax, majorOnly) {
12931293
for(var i = 0; i < vals.length; i++) {
12941294
var vali = tickVal2l(vals[i]);
12951295
if(vali > tickMin && vali < tickMax) {
1296-
var obj = text[i] === undefined ?
1297-
axes.tickText(ax, vali) :
1298-
tickTextObj(ax, vali, String(text[i]));
1299-
1296+
var obj = axes.tickText(ax, vali, false, String(text[i]));
13001297
if(isMinor) {
13011298
obj.minor = true;
13021299
obj.text = '';
@@ -1633,6 +1630,14 @@ axes.tickText = function(ax, x, hover, noSuffixPrefix) {
16331630
}
16341631
if(i < ax.ticktext.length) {
16351632
out.text = String(ax.ticktext[i]);
1633+
var inbounds = function(v) {
1634+
var p = ax.l2p(v);
1635+
return p >= 0 && p <= ax._length ? v : null;
1636+
};
1637+
out.xbnd = [
1638+
inbounds(out.x - 0.5),
1639+
inbounds(out.x + ax.dtick - 0.5)
1640+
];
16361641
return out;
16371642
}
16381643
}
@@ -2807,7 +2812,7 @@ function getBoundaryVals(ax, vals) {
28072812
// boundaryVals are never used for labels;
28082813
// no need to worry about the other tickTextObj keys
28092814
var _push = function(d, bndIndex) {
2810-
var xb = d.xbnd ? d.xbnd[bndIndex] : d.x;
2815+
var xb = d.xbnd[bndIndex];
28112816
if(xb !== null) {
28122817
out.push(Lib.extendFlat({}, d, {x: xb}));
28132818
}
@@ -3755,7 +3760,7 @@ axes.drawLabels = function(gd, ax, opts) {
37553760
// TODO should secondary labels also fall into this fix-overlap regime?
37563761

37573762
for(i = 0; i < lbbArray.length; i++) {
3758-
var xbnd = (vals && vals[i].xbnd) ? vals[i].xbnd : [null, null];
3763+
var xbnd = vals[i].xbnd;
37593764
var lbb = lbbArray[i];
37603765
if(
37613766
(xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) ||

0 commit comments

Comments
 (0)