Skip to content

Commit b46327c

Browse files
committed
fixup tickangle for inside tick labels
1 parent e01dc32 commit b46327c

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/plots/cartesian/axes.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,7 @@ axes.makeLabelFns = function(ax, shift, angle) {
26582658
out.xFn = function(d) { return d.dx + x0; };
26592659
out.yFn = function(d) { return d.dy + y0 + d.fontSize * ff; };
26602660
out.anchorFn = function(d, a) {
2661-
if(insideTickLabels || isAligned) {
2661+
if(isAligned) {
26622662
if(isLeft) return 'end';
26632663
if(isRight) return 'start';
26642664
}
@@ -2684,19 +2684,30 @@ axes.makeLabelFns = function(ax, shift, angle) {
26842684

26852685
x0 = labelStandoff;
26862686
y0 = labelShift * flipIt;
2687+
var tickangle = ax.tickangle;
26872688
ff = 0;
2688-
if(Math.abs(ax.tickangle) === 90) {
2689+
if(Math.abs(tickangle) === 90) {
26892690
if(
2690-
(ax.tickangle === -90 && side === 'left') ||
2691-
(ax.tickangle === 90 && side === 'right')
2691+
(tickangle === -90 && side === 'left') ||
2692+
(tickangle === 90 && side === 'right')
26922693
) {
26932694
ff = CAP_SHIFT;
26942695
} else {
26952696
ff = 0.5;
26962697
}
26972698
}
26982699

2699-
out.xFn = function(d) { return d.dx + shift - (x0 + d.fontSize * ff) * flipIt; };
2700+
var xQ = 0;
2701+
if(insideTickLabels) {
2702+
var ang = isNumeric(tickangle) ? +tickangle : 0;
2703+
if(ang !== 0) {
2704+
var rA = Lib.deg2rad(ang);
2705+
xQ = Math.abs(Math.sin(rA)) * CAP_SHIFT * flipIt;
2706+
ff = 0;
2707+
}
2708+
}
2709+
2710+
out.xFn = function(d) { return d.dx + shift - (x0 + d.fontSize * ff) * flipIt + xQ * d.fontSize; };
27002711
out.yFn = function(d) { return d.dy + y0 + d.fontSize * MID_SHIFT; };
27012712
out.anchorFn = function(d, a) {
27022713
if(isNumeric(a) && Math.abs(a) === 90) {
@@ -2706,7 +2717,8 @@ axes.makeLabelFns = function(ax, shift, angle) {
27062717
return endSide ? 'end' : 'start';
27072718
};
27082719
out.heightFn = function(d, a, h) {
2709-
a *= ax.side === 'left' ? 1 : -1;
2720+
if(ax.side === 'right') a *= -1;
2721+
27102722
return a < -30 ? -h :
27112723
a < 30 ? -0.5 * h :
27122724
0;
96 Bytes
Loading
255 Bytes
Loading

0 commit comments

Comments
 (0)