Skip to content

Commit a9f64b3

Browse files
authored
Merge pull request #3773 from plotly/bar-autotext-log-axis-fix
Fix more bar/text/log size axis cases
2 parents 2255212 + 03a9776 commit a9f64b3

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

src/traces/bar/plot.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,20 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1) {
232232
if(orientation === 'h') {
233233
var xa = plotinfo.xaxis;
234234
if(xa.type === 'log' && di.s0 <= 0) {
235-
x0 = xa._length;
235+
if(xa.range[0] < xa.range[1]) {
236+
x0 = 0;
237+
} else {
238+
x0 = xa._length;
239+
}
236240
}
237241
} else {
238242
var ya = plotinfo.yaxis;
239243
if(ya.type === 'log' && di.s0 <= 0) {
240-
y0 = ya._length;
244+
if(ya.range[0] < ya.range[1]) {
245+
y0 = ya._length;
246+
} else {
247+
y0 = 0;
248+
}
241249
}
242250
}
243251

Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"data": [{
3+
"type": "bar",
4+
"x": ["giraffes", "orangutans", "monkeys"],
5+
"y": [20, 14, 1],
6+
"text": ["giraffes", "orangutans", "monkeys"],
7+
"textposition": "auto"
8+
}, {
9+
"type": "bar",
10+
"x": ["giraffes", "orangutans", "monkeys"],
11+
"y": [20, 14, 1],
12+
"text": ["giraffes", "orangutans", "monkeys"],
13+
"textposition": "auto",
14+
"xaxis": "x2",
15+
"yaxis": "y2"
16+
}, {
17+
"type": "bar",
18+
"y": ["giraffes", "orangutans", "monkeys"],
19+
"x": [20, 14, 1],
20+
"text": ["giraffes", "orangutans", "monkeys"],
21+
"orientation": "h",
22+
"textposition": "auto",
23+
"xaxis": "x3",
24+
"yaxis": "y3"
25+
}, {
26+
"type": "bar",
27+
"y": ["giraffes", "orangutans", "monkeys"],
28+
"x": [20, 14, 1],
29+
"text": ["giraffes", "orangutans", "monkeys"],
30+
"orientation": "h",
31+
"textposition": "auto",
32+
"xaxis": "x4",
33+
"yaxis": "y4"
34+
}],
35+
"layout": {
36+
"showlegend": false,
37+
"grid": {"rows": 2, "columns": 2, "pattern": "independent", "xgap": 0.1, "ygap": 0.1},
38+
"xaxis": {"showticklabels": false},
39+
"yaxis": {"type": "log"},
40+
"xaxis2": {"showticklabels": false},
41+
"yaxis2": {"type": "log", "autorange": "reversed", "side": "right"},
42+
"xaxis3": {"type": "log"},
43+
"yaxis3": {"showticklabels": false},
44+
"xaxis4": {"type": "log", "autorange": "reversed"},
45+
"yaxis4": {"showticklabels": false},
46+
"width": 600,
47+
"height": 600,
48+
"margin": {"l": 20, "t": 20, "r": 20, "b": 20}
49+
}
50+
}

0 commit comments

Comments
 (0)