diff --git a/src/components/drawing/index.js b/src/components/drawing/index.js index 3aa65a573d6..2faf5f637ea 100644 --- a/src/components/drawing/index.js +++ b/src/components/drawing/index.js @@ -943,7 +943,8 @@ drawing.textPointStyle = function(s, trace, gd) { } if(texttemplate) { - var labels = trace._module.formatLabels ? trace._module.formatLabels(d, trace, fullLayout) : {}; + var fn = trace._module.formatLabels; + var labels = fn ? fn(d, trace, fullLayout) : {}; var pointValues = {}; appendArrayPointValue(pointValues, trace, d.i); var meta = trace._meta || {}; diff --git a/src/traces/bar/plot.js b/src/traces/bar/plot.js index fdc047eafc0..8923665593d 100644 --- a/src/traces/bar/plot.js +++ b/src/traces/bar/plot.js @@ -647,11 +647,11 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { } function formatLabel(u) { - return tickText(pAxis, u, true).text; + return tickText(pAxis, pAxis.c2l(u), true).text; } function formatNumber(v) { - return tickText(vAxis, +v, true).text; + return tickText(vAxis, vAxis.c2l(v), true).text; } var cdi = cd[index]; diff --git a/src/traces/scatter/format_labels.js b/src/traces/scatter/format_labels.js index a3604c7dd53..5908a425466 100644 --- a/src/traces/scatter/format_labels.js +++ b/src/traces/scatter/format_labels.js @@ -9,8 +9,8 @@ module.exports = function formatLabels(cdi, trace, fullLayout) { var xa = Axes.getFromTrace(mockGd, trace, 'x'); var ya = Axes.getFromTrace(mockGd, trace, 'y'); - labels.xLabel = Axes.tickText(xa, cdi.x, true).text; - labels.yLabel = Axes.tickText(ya, cdi.y, true).text; + labels.xLabel = Axes.tickText(xa, xa.c2l(cdi.x), true).text; + labels.yLabel = Axes.tickText(ya, ya.c2l(cdi.y), true).text; return labels; }; diff --git a/test/jasmine/tests/bar_test.js b/test/jasmine/tests/bar_test.js index 1d852eb04f0..41d826f93c0 100644 --- a/test/jasmine/tests/bar_test.js +++ b/test/jasmine/tests/bar_test.js @@ -2709,6 +2709,23 @@ describe('Text templates on bar traces:', function() { ['%{x}', ['Jan 1, 2019', 'Feb 1, 2019']] ]); + checkTextTemplate({ + data: [{ + type: 'bar', + textposition: 'outside', + x: [1, 2, 3], + y: [3, 2, 1], + hovertemplate: '%{x}-%{y}', + texttemplate: '%{x}-%{y}' + }], + layout: { + xaxis: {type: 'log'}, + yaxis: {type: 'log'}, + } + }, 'text.bartext', [ + ['%{x}-%{y}', ['1-3', '2-2', '3-1']] + ]); + checkTextTemplate({ data: [{ type: 'bar', diff --git a/test/jasmine/tests/scatter_test.js b/test/jasmine/tests/scatter_test.js index 4006d0b640f..80c7ff97e53 100644 --- a/test/jasmine/tests/scatter_test.js +++ b/test/jasmine/tests/scatter_test.js @@ -1241,6 +1241,22 @@ describe('Text templates on scatter traces:', function() { [['%{y}', '%{x}-%{y}'], ['1', '1-5', '', '']] ]); + checkTextTemplate({ + data: [{ + type: 'scatter', + mode: 'text', + x: [1, 2, 3], + y: [3, 2, 1], + texttemplate: '%{x}-%{y}' + }], + layout: { + xaxis: {type: 'log'}, + yaxis: {type: 'log'}, + } + }, '.textpoint', [ + ['%{x}-%{y}', ['1-3', '2-2', '3-1']] + ]); + checkTextTemplate({ data: [{ type: 'scatter',