Skip to content

Commit e0ea4d2

Browse files
authored
Merge pull request #5638 from plotly/bar-textposition-auto
Revise textposition default for bar, histogram and waterfall
2 parents b292bec + f1e2c6c commit e0ea4d2

28 files changed

+31
-77
lines changed

src/traces/bar/attributes.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
textposition: {
7575
valType: 'enumerated',
7676
values: ['inside', 'outside', 'auto', 'none'],
77-
dflt: 'none',
77+
dflt: 'auto',
7878
arrayOk: true,
7979
editType: 'calc',
8080
description: [
@@ -86,7 +86,8 @@ module.exports = {
8686
'this one, then the text gets pushed inside.',
8787
'*auto* tries to position `text` inside the bar, but if',
8888
'the bar is too small and no bar is stacked on this one',
89-
'the text is moved outside.'
89+
'the text is moved outside.',
90+
'If *none*, no text appears.'
9091
].join(' ')
9192
},
9293

src/traces/funnel/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
}),
5555

5656
text: barAttrs.text,
57-
textposition: extendFlat({}, barAttrs.textposition, {dflt: 'auto'}),
57+
textposition: barAttrs.textposition,
5858
insidetextanchor: extendFlat({}, barAttrs.insidetextanchor, {dflt: 'middle'}),
5959
textangle: extendFlat({}, barAttrs.textangle, {dflt: 0}),
6060
textfont: barAttrs.textfont,
33.7 KB
Loading

test/image/mocks/bar-autotext-log-size-axes.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
"type": "bar",
44
"x": ["giraffes", "orangutans", "monkeys"],
55
"y": [20, 14, 1],
6-
"text": ["giraffes", "orangutans", "monkeys"],
7-
"textposition": "auto"
6+
"text": ["giraffes", "orangutans", "monkeys"]
87
}, {
98
"type": "bar",
109
"x": ["giraffes", "orangutans", "monkeys"],
1110
"y": [20, 14, 1],
1211
"text": ["giraffes", "orangutans", "monkeys"],
13-
"textposition": "auto",
1412
"xaxis": "x2",
1513
"yaxis": "y2"
1614
}, {
@@ -19,7 +17,6 @@
1917
"x": [20, 14, 1],
2018
"text": ["giraffes", "orangutans", "monkeys"],
2119
"orientation": "h",
22-
"textposition": "auto",
2320
"xaxis": "x3",
2421
"yaxis": "y3"
2522
}, {
@@ -28,7 +25,6 @@
2825
"x": [20, 14, 1],
2926
"text": ["giraffes", "orangutans", "monkeys"],
3027
"orientation": "h",
31-
"textposition": "auto",
3228
"xaxis": "x4",
3329
"yaxis": "y4"
3430
}],

test/image/mocks/bar-like_textangle45.json

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"invisible"
1313
],
1414
"type": "bar",
15-
"textposition": "auto",
1615
"textangle": -45,
1716
"xaxis": "x",
1817
"yaxis": "y"
@@ -29,7 +28,6 @@
2928
"visible"
3029
],
3130
"type": "bar",
32-
"textposition": "auto",
3331
"textangle": -45,
3432
"xaxis": "x",
3533
"yaxis": "y"

test/image/mocks/bar-like_textangle60.json

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"invisible"
1313
],
1414
"type": "bar",
15-
"textposition": "auto",
1615
"textangle": -60,
1716
"xaxis": "x",
1817
"yaxis": "y"
@@ -29,7 +28,6 @@
2928
"visible"
3029
],
3130
"type": "bar",
32-
"textposition": "auto",
3331
"textangle": -60,
3432
"xaxis": "x",
3533
"yaxis": "y"

test/image/mocks/bar-like_traces_tozero.json

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"-11",
2121
"+1"
2222
],
23-
"textposition": "auto",
2423
"insidetextanchor": "middle",
2524
"base": 10
2625
},
@@ -43,7 +42,6 @@
4342
"+11",
4443
"-1"
4544
],
46-
"textposition": "auto",
4745
"insidetextanchor": "middle",
4846
"base": -10
4947
},
@@ -66,7 +64,6 @@
6664
"-12",
6765
"+1"
6866
],
69-
"textposition": "auto",
7067
"insidetextanchor": "middle",
7168
"base": 10
7269
},
@@ -90,7 +87,6 @@
9087
"+12",
9188
"-1"
9289
],
93-
"textposition": "auto",
9490
"insidetextanchor": "middle",
9591
"base": -10
9692
}

test/image/mocks/bar_display_height_zero.json

-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
null,
2323
1
2424
],
25-
"textposition": "auto",
2625
"insidetextanchor": "middle",
2726
"cliponaxis": false
2827
},
@@ -48,7 +47,6 @@
4847
null,
4948
1
5049
],
51-
"textposition": "auto",
5250
"insidetextanchor": "middle",
5351
"cliponaxis": false,
5452
"xaxis": "x2",
@@ -77,7 +75,6 @@
7775
null,
7876
1
7977
],
80-
"textposition": "auto",
8178
"insidetextanchor": "middle",
8279
"cliponaxis": false,
8380
"xaxis": "x3",
@@ -106,7 +103,6 @@
106103
null,
107104
1
108105
],
109-
"textposition": "auto",
110106
"insidetextanchor": "middle",
111107
"cliponaxis": false,
112108
"xaxis": "x4",

test/image/mocks/bar_display_height_zero_no_line_width.json

-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
0.75,
2424
1
2525
],
26-
"textposition": "auto",
2726
"insidetextanchor": "middle",
2827
"cliponaxis": false
2928
},
@@ -55,7 +54,6 @@
5554
null,
5655
1
5756
],
58-
"textposition": "auto",
5957
"insidetextanchor": "middle",
6058
"cliponaxis": false
6159
},
@@ -82,7 +80,6 @@
8280
0.75,
8381
1
8482
],
85-
"textposition": "auto",
8683
"insidetextanchor": "middle",
8784
"cliponaxis": false,
8885
"xaxis": "x2",
@@ -116,7 +113,6 @@
116113
null,
117114
1
118115
],
119-
"textposition": "auto",
120116
"insidetextanchor": "middle",
121117
"cliponaxis": false,
122118
"xaxis": "x2",
@@ -146,7 +142,6 @@
146142
0.75,
147143
1
148144
],
149-
"textposition": "auto",
150145
"insidetextanchor": "middle",
151146
"cliponaxis": false,
152147
"xaxis": "x3",
@@ -181,7 +176,6 @@
181176
null,
182177
1
183178
],
184-
"textposition": "auto",
185179
"insidetextanchor": "middle",
186180
"cliponaxis": false,
187181
"xaxis": "x3",
@@ -211,7 +205,6 @@
211205
0.75,
212206
1
213207
],
214-
"textposition": "auto",
215208
"insidetextanchor": "middle",
216209
"cliponaxis": false,
217210
"xaxis": "x4",
@@ -246,7 +239,6 @@
246239
null,
247240
1
248241
],
249-
"textposition": "auto",
250242
"insidetextanchor": "middle",
251243
"cliponaxis": false,
252244
"xaxis": "x4",

test/image/mocks/bar_display_height_zero_only_line_width.json

-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
null,
2929
1
3030
],
31-
"textposition": "auto",
3231
"insidetextanchor": "middle",
3332
"cliponaxis": false
3433
},
@@ -60,7 +59,6 @@
6059
null,
6160
1
6261
],
63-
"textposition": "auto",
6462
"insidetextanchor": "middle",
6563
"cliponaxis": false
6664
},
@@ -92,7 +90,6 @@
9290
null,
9391
1
9492
],
95-
"textposition": "auto",
9693
"insidetextanchor": "middle",
9794
"cliponaxis": false,
9895
"xaxis": "x2",
@@ -126,7 +123,6 @@
126123
null,
127124
1
128125
],
129-
"textposition": "auto",
130126
"insidetextanchor": "middle",
131127
"cliponaxis": false,
132128
"xaxis": "x2",
@@ -161,7 +157,6 @@
161157
null,
162158
1
163159
],
164-
"textposition": "auto",
165160
"insidetextanchor": "middle",
166161
"cliponaxis": false,
167162
"xaxis": "x3",
@@ -196,7 +191,6 @@
196191
null,
197192
1
198193
],
199-
"textposition": "auto",
200194
"insidetextanchor": "middle",
201195
"cliponaxis": false,
202196
"xaxis": "x3",
@@ -231,7 +225,6 @@
231225
null,
232226
1
233227
],
234-
"textposition": "auto",
235228
"insidetextanchor": "middle",
236229
"cliponaxis": false,
237230
"xaxis": "x4",
@@ -266,7 +259,6 @@
266259
null,
267260
1
268261
],
269-
"textposition": "auto",
270262
"insidetextanchor": "middle",
271263
"cliponaxis": false,
272264
"xaxis": "x4",

test/image/mocks/bar_hide_nulls.json

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
0.001,
2121
1
2222
],
23-
"textposition": "auto",
2423
"insidetextanchor": "middle",
2524
"cliponaxis": false
2625
},
@@ -44,7 +43,6 @@
4443
0.001,
4544
1
4645
],
47-
"textposition": "auto",
4846
"insidetextanchor": "middle",
4947
"cliponaxis": false,
5048
"xaxis": "x2",
@@ -71,7 +69,6 @@
7169
0.001,
7270
1
7371
],
74-
"textposition": "auto",
7572
"insidetextanchor": "middle",
7673
"cliponaxis": false,
7774
"xaxis": "x3",
@@ -98,7 +95,6 @@
9895
0.001,
9996
1
10097
],
101-
"textposition": "auto",
10298
"insidetextanchor": "middle",
10399
"cliponaxis": false,
104100
"xaxis": "x4",

test/image/mocks/display-text_zero-number.json

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"measure": ["r", "r", "r", "r", "r", "t", "a"],
4242
"text": [null, "", "0", 0, 1, true, false],
4343
"textinfo": "label+text+final",
44-
"textposition": "auto",
4544
"xaxis": "x2",
4645
"yaxis": "y2"
4746
}

test/image/mocks/mathjax.json

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"x": [0, 1],
1010
"y": [1.4, 0.1],
1111
"text": ["H1.400 \\pm 0.023H", "H0.100 \\pm 0.002H"],
12-
"textposition": "auto",
1312
"type": "bar",
1413
"name": "$x=\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}$"
1514
}, {

test/image/mocks/uniformtext_bar-like_10_auto.json

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"invisible"
1313
],
1414
"type": "bar",
15-
"textposition": "auto",
1615
"xaxis": "x",
1716
"yaxis": "y"
1817
},
@@ -28,7 +27,6 @@
2827
"visible"
2928
],
3029
"type": "bar",
31-
"textposition": "auto",
3230
"xaxis": "x",
3331
"yaxis": "y"
3432
},

test/image/mocks/uniformtext_bar-like_8_horizontal.json

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
],
1414
"type": "bar",
1515
"textangle": 0,
16-
"textposition": "auto",
1716
"xaxis": "x",
1817
"yaxis": "y"
1918
},
@@ -30,7 +29,6 @@
3029
],
3130
"type": "bar",
3231
"textangle": 0,
33-
"textposition": "auto",
3432
"xaxis": "x",
3533
"yaxis": "y"
3634
},

test/image/mocks/uniformtext_bar-like_8_textangle.json

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"invisible"
1313
],
1414
"type": "bar",
15-
"textposition": "auto",
1615
"textangle": -90,
1716
"xaxis": "x",
1817
"yaxis": "y"
@@ -29,7 +28,6 @@
2928
"visible"
3029
],
3130
"type": "bar",
32-
"textposition": "auto",
3331
"textangle": -90,
3432
"xaxis": "x",
3533
"yaxis": "y"

test/image/mocks/uniformtext_bar-like_8_textangle45.json

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"invisible"
1313
],
1414
"type": "bar",
15-
"textposition": "auto",
1615
"textangle": -45,
1716
"xaxis": "x",
1817
"yaxis": "y"
@@ -29,7 +28,6 @@
2928
"visible"
3029
],
3130
"type": "bar",
32-
"textposition": "auto",
3331
"textangle": -45,
3432
"xaxis": "x",
3533
"yaxis": "y"

0 commit comments

Comments
 (0)