diff --git a/src/traces/bar/plot.js b/src/traces/bar/plot.js index d013f7ec46f..9466ce9a061 100644 --- a/src/traces/bar/plot.js +++ b/src/traces/bar/plot.js @@ -232,12 +232,20 @@ function appendBarText(gd, plotinfo, bar, calcTrace, i, x0, x1, y0, y1) { if(orientation === 'h') { var xa = plotinfo.xaxis; if(xa.type === 'log' && di.s0 <= 0) { - x0 = xa._length; + if(xa.range[0] < xa.range[1]) { + x0 = 0; + } else { + x0 = xa._length; + } } } else { var ya = plotinfo.yaxis; if(ya.type === 'log' && di.s0 <= 0) { - y0 = ya._length; + if(ya.range[0] < ya.range[1]) { + y0 = ya._length; + } else { + y0 = 0; + } } } diff --git a/test/image/baselines/bar-autotext-log-size-axes.png b/test/image/baselines/bar-autotext-log-size-axes.png new file mode 100644 index 00000000000..63f3afe2730 Binary files /dev/null and b/test/image/baselines/bar-autotext-log-size-axes.png differ diff --git a/test/image/mocks/bar-autotext-log-size-axes.json b/test/image/mocks/bar-autotext-log-size-axes.json new file mode 100644 index 00000000000..976c11eeb24 --- /dev/null +++ b/test/image/mocks/bar-autotext-log-size-axes.json @@ -0,0 +1,50 @@ +{ + "data": [{ + "type": "bar", + "x": ["giraffes", "orangutans", "monkeys"], + "y": [20, 14, 1], + "text": ["giraffes", "orangutans", "monkeys"], + "textposition": "auto" + }, { + "type": "bar", + "x": ["giraffes", "orangutans", "monkeys"], + "y": [20, 14, 1], + "text": ["giraffes", "orangutans", "monkeys"], + "textposition": "auto", + "xaxis": "x2", + "yaxis": "y2" + }, { + "type": "bar", + "y": ["giraffes", "orangutans", "monkeys"], + "x": [20, 14, 1], + "text": ["giraffes", "orangutans", "monkeys"], + "orientation": "h", + "textposition": "auto", + "xaxis": "x3", + "yaxis": "y3" + }, { + "type": "bar", + "y": ["giraffes", "orangutans", "monkeys"], + "x": [20, 14, 1], + "text": ["giraffes", "orangutans", "monkeys"], + "orientation": "h", + "textposition": "auto", + "xaxis": "x4", + "yaxis": "y4" + }], + "layout": { + "showlegend": false, + "grid": {"rows": 2, "columns": 2, "pattern": "independent", "xgap": 0.1, "ygap": 0.1}, + "xaxis": {"showticklabels": false}, + "yaxis": {"type": "log"}, + "xaxis2": {"showticklabels": false}, + "yaxis2": {"type": "log", "autorange": "reversed", "side": "right"}, + "xaxis3": {"type": "log"}, + "yaxis3": {"showticklabels": false}, + "xaxis4": {"type": "log", "autorange": "reversed"}, + "yaxis4": {"showticklabels": false}, + "width": 600, + "height": 600, + "margin": {"l": 20, "t": 20, "r": 20, "b": 20} + } +}