Skip to content

Commit 134a7a2

Browse files
committed
add pad to labelStandoff Axes.makeLabelFns output
... to make it easier to reuse.
1 parent 7bdbd79 commit 134a7a2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/plots/cartesian/axes.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,29 +2181,29 @@ axes.makeTickPath = function(ax, shift, sgn, len) {
21812181
* - {fn} labelXFn
21822182
* - {fn} labelYFn
21832183
* - {fn} labelAnchorFn
2184-
* - {number} labelStandoff
2185-
* - {number} labelShift
2184+
* - {number} labelStandoff (gap parallel to ticks)
2185+
* - {number} labelShift (gap perpendicular to ticks)
21862186
*/
21872187
axes.makeLabelFns = function(ax, shift, angle) {
21882188
var axLetter = ax._id.charAt(0);
2189-
var pad = (ax.linewidth || 1) / 2;
21902189
var ticksOnOutsideLabels = ax.tickson !== 'boundaries' && ax.ticks === 'outside';
21912190

2192-
var labelStandoff = ticksOnOutsideLabels ? ax.ticklen : 0;
2191+
var labelStandoff = 0;
21932192
var labelShift = 0;
21942193

2194+
if(ticksOnOutsideLabels) {
2195+
labelStandoff += ax.ticklen;
2196+
}
21952197
if(angle && ax.ticks === 'outside') {
21962198
var rad = Lib.deg2rad(angle);
21972199
labelStandoff = ax.ticklen * Math.cos(rad) + 1;
21982200
labelShift = ax.ticklen * Math.sin(rad);
21992201
}
2200-
22012202
if(ax.showticklabels && (ticksOnOutsideLabels || ax.showline)) {
22022203
labelStandoff += 0.2 * ax.tickfont.size;
22032204
}
2205+
labelStandoff += (ax.linewidth || 1) / 2;
22042206

2205-
// Used in polar angular label x/y functions
2206-
// TODO generalize makeLabelFns so that it just work for angular axes
22072207
var out = {
22082208
labelStandoff: labelStandoff,
22092209
labelShift: labelShift
@@ -2213,7 +2213,7 @@ axes.makeLabelFns = function(ax, shift, angle) {
22132213
if(axLetter === 'x') {
22142214
flipIt = ax.side === 'bottom' ? 1 : -1;
22152215
x0 = labelShift * flipIt;
2216-
y0 = shift + (labelStandoff + pad) * flipIt;
2216+
y0 = shift + labelStandoff * flipIt;
22172217
ff = ax.side === 'bottom' ? 1 : -0.2;
22182218

22192219
out.labelXFn = function(d) { return d.dx + x0; };
@@ -2226,7 +2226,7 @@ axes.makeLabelFns = function(ax, shift, angle) {
22262226
};
22272227
} else if(axLetter === 'y') {
22282228
flipIt = ax.side === 'right' ? 1 : -1;
2229-
x0 = labelStandoff + pad;
2229+
x0 = labelStandoff;
22302230
y0 = -labelShift * flipIt;
22312231
ff = Math.abs(ax.tickangle) === 90 ? 0.5 : 0;
22322232

0 commit comments

Comments
 (0)