Skip to content

Commit 5858067

Browse files
committed
move Axes.drawTitle out of Axes.drawLabels
1 parent 7033585 commit 5858067

File tree

4 files changed

+31
-43
lines changed

4 files changed

+31
-43
lines changed

src/components/colorbar/draw.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ module.exports = function draw(gd, id) {
456456
transFn: transFn,
457457
labelXFn: labelFns.labelXFn,
458458
labelYFn: labelFns.labelYFn,
459-
labelAnchorFn: labelFns.labelAnchorFn,
460-
skipTitle: true
459+
labelAnchorFn: labelFns.labelAnchorFn
461460
});
462461
},
463462
function() {

src/plots/cartesian/axes.js

+27-35
Original file line numberDiff line numberDiff line change
@@ -1679,27 +1679,39 @@ axes.drawOne = function(gd, ax, opts) {
16791679
});
16801680
}
16811681

1682+
var labelFns = axes.makeLabelFns(ax, ax._mainLinePosition);
16821683
// stash tickLabels selection, so that drawTitle can use it
16831684
// to scoot title w/o having to query the axis layer again
16841685
ax._tickLabels = null;
1685-
var labelFns = axes.makeLabelFns(ax, ax._mainLinePosition);
1686+
1687+
var seq = [];
16861688

16871689
// tick labels - for now just the main labels.
16881690
// TODO: mirror labels, esp for subplots
1689-
return axes.drawLabels(gd, ax, {
1690-
vals: vals,
1691-
layer: mainPlotinfo[axLetter + 'axislayer'],
1692-
// TODO shouldn't need this
1693-
shift: ax._mainLinePosition,
1694-
// TODO calcBoundingBox should be taken out of drawLabels
1695-
subplotsWithAx: subplotsWithAx,
1696-
transFn: transFn,
1697-
labelXFn: labelFns.labelXFn,
1698-
labelYFn: labelFns.labelYFn,
1699-
labelAnchorFn: labelFns.labelAnchorFn,
1700-
// TODO call drawTitle after drawLabels
1701-
skipTitle: opts.skipTitle
1691+
seq.push(function() {
1692+
return axes.drawLabels(gd, ax, {
1693+
vals: vals,
1694+
layer: mainPlotinfo[axLetter + 'axislayer'],
1695+
// TODO shouldn't need this
1696+
shift: ax._mainLinePosition,
1697+
// TODO calcBoundingBox should be taken out of drawLabels
1698+
subplotsWithAx: subplotsWithAx,
1699+
transFn: transFn,
1700+
labelXFn: labelFns.labelXFn,
1701+
labelYFn: labelFns.labelYFn,
1702+
labelAnchorFn: labelFns.labelAnchorFn,
1703+
});
17021704
});
1705+
1706+
if(!opts.skipTitle &&
1707+
!((ax.rangeslider || {}).visible && ax._boundingBox && ax.side === 'bottom')
1708+
) {
1709+
seq.push(function() {
1710+
return axes.drawTitle(gd, ax);
1711+
});
1712+
}
1713+
1714+
return Lib.syncOrAsync(seq);
17031715
};
17041716

17051717
/**
@@ -1911,12 +1923,10 @@ axes.drawLabels = function(gd, ax, opts) {
19111923

19121924
if(!isNumeric(opts.shift)) {
19131925
tickLabels.remove();
1914-
axes.drawTitle(gd, ax, opts);
19151926
return;
19161927
}
19171928
if(!ax.showticklabels) {
19181929
tickLabels.remove();
1919-
axes.drawTitle(gd, ax, opts);
19201930
calcBoundingBox();
19211931
return;
19221932
}
@@ -2087,13 +2097,6 @@ axes.drawLabels = function(gd, ax, opts) {
20872097
}
20882098
ax._lastangle = autoangle;
20892099
}
2090-
2091-
// update the axis title
2092-
// (so it can move out of the way if needed)
2093-
// TODO: separate out scoot so we don't need to do
2094-
// a full redraw of the title (mostly relevant for MathJax)
2095-
axes.drawTitle(gd, ax, opts);
2096-
return axId + ' done';
20972100
}
20982101

20992102
function calcBoundingBox() {
@@ -2223,18 +2226,7 @@ axes.drawLabels = function(gd, ax, opts) {
22232226
return done;
22242227
};
22252228

2226-
axes.drawTitle = function(gd, ax, opts) {
2227-
opts = opts || {};
2228-
2229-
// Now this only applies to regular cartesian axes; colorbars and
2230-
// others ALWAYS call doTicksSingle with skipTitle=true so they can
2231-
// configure their own titles.
2232-
//
2233-
// Rangeslider takes over a bottom title so drop it here
2234-
if(opts.skipTitle ||
2235-
((ax.rangeslider || {}).visible && ax._boundingBox && ax.side === 'bottom')
2236-
) return;
2237-
2229+
axes.drawTitle = function(gd, ax) {
22382230
var fullLayout = gd._fullLayout;
22392231
var tickLabels = ax._tickLabels;
22402232

src/plots/polar/polar.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ proto.updateRadialAxis = function(fullLayout, polarLayout) {
430430
transFn: transFn,
431431
labelXFn: labelFns.labelXFn,
432432
labelYFn: labelFns.labelYFn,
433-
labelAnchorFn: labelFns.labelAnchorFn,
434-
skipTitle: true
433+
labelAnchorFn: labelFns.labelAnchorFn
435434
});
436435
}
437436

@@ -645,8 +644,7 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) {
645644
transFn: transFn,
646645
labelXFn: labelXFn,
647646
labelYFn: labelYFn,
648-
labelAnchorFn: labelAnchorFn,
649-
skipTitle: true
647+
labelAnchorFn: labelAnchorFn
650648
});
651649
}
652650

src/plots/ternary/ternary.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,7 @@ proto.drawAx = function(ax) {
466466
transFn: transFn,
467467
labelXFn: labelFns.labelXFn,
468468
labelYFn: labelFns.labelYFn,
469-
labelAnchorFn: labelFns.labelAnchorFn,
470-
skipTitle: true
469+
labelAnchorFn: labelFns.labelAnchorFn
471470
});
472471
};
473472

0 commit comments

Comments
 (0)