Skip to content

Commit 8f69805

Browse files
authored
Merge pull request #5582 from plotly/hide-period-label-intersecting-inside-label
Hide period label intersecting inside tick labels of the counter axis
2 parents c35e5c4 + 45e3e3d commit 8f69805

File tree

5 files changed

+124
-7
lines changed

5 files changed

+124
-7
lines changed

src/plots/cartesian/axes.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -3132,8 +3132,10 @@ axes.drawLabels = function(gd, ax, opts) {
31323132
TICK_PATH,
31333133
TICK_TEXT
31343134
]).forEach(function(e) {
3135-
var isTickText = e.K === 'tick' && e.L === 'text';
3136-
if(isTickText && ax.ticklabelmode === 'period') return;
3135+
var isPeriodLabel =
3136+
e.K === 'tick' &&
3137+
e.L === 'text' &&
3138+
ax.ticklabelmode === 'period';
31373139

31383140
var sel;
31393141
if(e.K === ZERO_PATH.K) sel = opts.plotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl');
@@ -3145,7 +3147,9 @@ axes.drawLabels = function(gd, ax, opts) {
31453147
if(e.L) w = w.selectAll(e.L);
31463148

31473149
w.each(function(d) {
3148-
var q = ax.l2p(d.x) + ax._offset;
3150+
var q = ax.l2p(
3151+
isPeriodLabel ? getPosX(d) : d.x
3152+
) + ax._offset;
31493153

31503154
var t = d3.select(this);
31513155
if(q < ax._visibleLabelMax && q > ax._visibleLabelMin) {
36.8 KB
Loading

test/image/mocks/ticklabelposition-6.json

-4
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,21 @@
22
"data": [{
33
"xaxis": "x",
44
"yaxis": "y",
5-
"orientation": "h",
65
"x": [0.4, 0.5, 0.6, 0.7, 0.8],
76
"y": ["Oo", "Pp", "Qq", "Rr", "Ss"]
87
}, {
98
"xaxis": "x2",
109
"yaxis": "y2",
11-
"orientation": "h",
1210
"x": [0.4, 0.5, 0.6, 0.7, 0.8],
1311
"y": ["Oo", "Pp", "Qq", "Rr", "Ss"]
1412
}, {
1513
"xaxis": "x3",
1614
"yaxis": "y3",
17-
"orientation": "v",
1815
"y": [0.4, 0.5, 0.6, 0.7, 0.8],
1916
"x": ["Oo", "Pp", "Qq", "Rr", "Ss"]
2017
}, {
2118
"xaxis": "x4",
2219
"yaxis": "y4",
23-
"orientation": "v",
2420
"y": [0.4, 0.5, 0.6, 0.7, 0.8],
2521
"x": ["Oo", "Pp", "Qq", "Rr", "Ss"]
2622
}],
+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"data": [{
3+
"xaxis": "x",
4+
"yaxis": "y",
5+
"x": ["20-10", "21-03"],
6+
"y": [1e-1, 1e+6]
7+
}, {
8+
"xaxis": "x2",
9+
"yaxis": "y2",
10+
"x": ["21-03", "20-10"],
11+
"y": [1e+6, 1e-1]
12+
}, {
13+
"xaxis": "x3",
14+
"yaxis": "y3",
15+
"x": ["20", "23"],
16+
"y": [1e-1, 1e+6]
17+
}, {
18+
"xaxis": "x4",
19+
"yaxis": "y4",
20+
"x": ["23", "20"],
21+
"y": [1e+6, 1e-1]
22+
}],
23+
"layout": {
24+
"xaxis": {
25+
"anchor": "y",
26+
"domain": [0, 0.475],
27+
"type": "date",
28+
"ticks": "outside",
29+
"ticklabelmode": "period",
30+
"side": "bottom",
31+
"gridcolor": "white"
32+
},
33+
"yaxis": {
34+
"anchor": "x",
35+
"domain": [0, 0.475],
36+
"type": "log",
37+
"side": "left",
38+
"ticks": "inside",
39+
"ticklabelposition": "inside bottom",
40+
"gridcolor": "white"
41+
},
42+
"xaxis2": {
43+
"anchor": "y2",
44+
"domain": [0.525, 1],
45+
"autorange": "reversed",
46+
"type": "date",
47+
"ticks": "outside",
48+
"ticklabelmode": "period",
49+
"side": "bottom",
50+
"ticklabelposition": "inside left",
51+
"gridcolor": "white"
52+
},
53+
"yaxis2": {
54+
"anchor": "x2",
55+
"domain": [0, 0.475],
56+
"type": "log",
57+
"side": "right",
58+
"ticks": "inside",
59+
"ticklabelposition": "inside bottom",
60+
"gridcolor": "white"
61+
},
62+
"xaxis3": {
63+
"anchor": "y3",
64+
"domain": [0.525, 1],
65+
"type": "date",
66+
"ticks": "outside",
67+
"ticklabelmode": "period",
68+
"side": "top",
69+
"ticklabelposition": "inside right",
70+
"gridcolor": "white"
71+
},
72+
"yaxis3": {
73+
"anchor": "x3",
74+
"domain": [0.525, 1],
75+
"type": "log",
76+
"side": "right",
77+
"ticks": "inside",
78+
"ticklabelposition": "inside bottom",
79+
"gridcolor": "white"
80+
},
81+
"xaxis4": {
82+
"anchor": "y4",
83+
"domain": [0, 0.475],
84+
"autorange": "reversed",
85+
"type": "date",
86+
"ticks": "outside",
87+
"ticklabelmode": "period",
88+
"side": "top",
89+
"gridcolor": "white"
90+
},
91+
"yaxis4": {
92+
"anchor": "x4",
93+
"domain": [0.525, 1],
94+
"type": "log",
95+
"side": "left",
96+
"ticks": "inside",
97+
"ticklabelposition": "inside bottom",
98+
"gridcolor": "white"
99+
},
100+
"plot_bgcolor": "lightblue",
101+
"showlegend": false,
102+
"width": 500,
103+
"height": 500,
104+
"margin": {
105+
"t": 50,
106+
"b": 50,
107+
"l": 50,
108+
"r": 50
109+
}
110+
}
111+
}

test/jasmine/tests/mock_test.js

+6
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,9 @@ var list = [
969969
'ticklabelposition-2',
970970
'ticklabelposition-3',
971971
'ticklabelposition-4',
972+
'ticklabelposition-5',
973+
'ticklabelposition-6',
974+
'ticklabelposition-7',
972975
'ticklabelposition-a',
973976
'ticklabelposition-b',
974977
'ticklabelposition-c',
@@ -2059,6 +2062,9 @@ figs['ticklabelposition-1'] = require('@mocks/ticklabelposition-1');
20592062
figs['ticklabelposition-2'] = require('@mocks/ticklabelposition-2');
20602063
figs['ticklabelposition-3'] = require('@mocks/ticklabelposition-3');
20612064
figs['ticklabelposition-4'] = require('@mocks/ticklabelposition-4');
2065+
figs['ticklabelposition-5'] = require('@mocks/ticklabelposition-5');
2066+
figs['ticklabelposition-6'] = require('@mocks/ticklabelposition-6');
2067+
figs['ticklabelposition-7'] = require('@mocks/ticklabelposition-7');
20622068
figs['ticklabelposition-a'] = require('@mocks/ticklabelposition-a');
20632069
figs['ticklabelposition-b'] = require('@mocks/ticklabelposition-b');
20642070
figs['ticklabelposition-c'] = require('@mocks/ticklabelposition-c');

0 commit comments

Comments
 (0)