Skip to content

Commit 7bb3379

Browse files
committed
texttemplate: text in legends should not changed
1 parent 32498f8 commit 7bb3379

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

src/components/drawing/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ function extracTextFontSize(d, trace) {
680680
}
681681

682682
// draw text at points
683-
drawing.textPointStyle = function(s, trace, gd) {
683+
drawing.textPointStyle = function(s, trace, gd, inLegend) {
684684
if(!s.size()) return;
685685

686686
var selectedTextColorFn;
@@ -691,6 +691,8 @@ drawing.textPointStyle = function(s, trace, gd) {
691691
}
692692

693693
var template = trace.texttemplate;
694+
// If styling text in legends, do not use texttemplate
695+
if(inLegend) template = false;
694696
s.each(function(d) {
695697
var p = d3.select(this);
696698
var text = Lib.extractOption(d, trace, template ? 'txt' : 'tx', template ? 'texttemplate' : 'text');

src/components/legend/style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ module.exports = function style(s, gd) {
271271
.append('g').classed('pointtext', true)
272272
.append('text').attr('transform', 'translate(20,0)');
273273
txt.exit().remove();
274-
txt.selectAll('text').call(Drawing.textPointStyle, tMod, gd);
274+
txt.selectAll('text').call(Drawing.textPointStyle, tMod, gd, true);
275275
}
276276

277277
function styleWaterfalls(d) {
Loading

test/image/baselines/texttemplate.png

-2 Bytes
Loading

test/image/mocks/gl3d_scatter3d-texttemplate.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77
"text": ["A", "B", "C"],
88
"texttemplate": "%{text}: (%{x}, %{y}, %{z})",
99
"mode": "markers+text"
10-
}],
10+
}, {
11+
"type": "scatter3d",
12+
"x": [2, 1, 0],
13+
"y": [0, 4, 1],
14+
"z": [-5, -2, 4],
15+
"texttemplate": ["1", "2"],
16+
"mode": "markers+text"
17+
}],
1118
"layout": {
19+
"showlegend": true,
1220
"width": 400,
1321
"height": 400,
1422
"margin": {"t": 20, "l": 0, "r": 0, "b": 0}

0 commit comments

Comments
 (0)