Skip to content

Commit cbbcfcb

Browse files
committed
texttemplate: use d3locale in GL traces, fix style
1 parent 2d50269 commit cbbcfcb

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

src/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ function templateFormatString(string, labels, d3locale) {
10671067

10681068
if(format) {
10691069
var fmt;
1070-
if(d3locale && d3locale.numberFormat) {
1070+
if(d3locale) {
10711071
fmt = d3locale.numberFormat;
10721072
} else {
10731073
fmt = d3.format;

src/traces/scatter/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ module.exports = {
168168
].join(' ')
169169
},
170170

171-
texttemplate: texttemplateAttrs({arrayOk: true}, {
171+
texttemplate: texttemplateAttrs({}, {
172172

173173
}),
174174
hovertext: {

src/traces/scatter3d/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ var attrs = module.exports = overrideAll({
8686
'these elements will be seen in the hover labels.'
8787
].join(' ')
8888
}),
89-
texttemplate: texttemplateAttrs({arrayOk: true}, {
89+
texttemplate: texttemplateAttrs({}, {
9090

9191
}),
9292
hovertext: extendFlat({}, scatterAttrs.hovertext, {

src/traces/scatter3d/convert.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,22 @@ function convertPlotlyOptions(scene, data) {
243243

244244
// check texttemplate
245245
if(data.texttemplate) {
246+
var d3locale = scene.fullLayout._d3locale;
246247
if(Array.isArray(data.texttemplate)) {
247248
text = new Array(data.texttemplate.length);
248249
for(i = 0; i < data.texttemplate.length; i++) {
249250
var pt = {};
250251
pt.text = text[i];
251252
appendArrayPointValue(pt, data, i);
252-
text[i] = Lib.texttemplateString(data.texttemplate[i], pt, function() {}, pt);
253+
text[i] = Lib.texttemplateString(data.texttemplate[i], pt, d3locale, pt);
253254
}
254255
} else {
255256
text = new Array(len);
256257
for(i = 0; i < len; i++) {
257258
var pt1 = {};
258259
pt1.text = text[i];
259260
appendArrayPointValue(pt1, data, i);
260-
text[i] = Lib.texttemplateString(data.texttemplate, pt1, function() {}, pt1);
261+
text[i] = Lib.texttemplateString(data.texttemplate, pt1, d3locale, pt1);
261262
}
262263
}
263264
}

src/traces/scattergl/convert.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function convertStyle(gd, trace) {
4949
if(trace.visible !== true) return opts;
5050

5151
if(subTypes.hasText(trace)) {
52-
opts.text = convertTextStyle(trace);
52+
opts.text = convertTextStyle(trace, gd);
5353
opts.textSel = convertTextSelection(trace, trace.selected);
5454
opts.textUnsel = convertTextSelection(trace, trace.unselected);
5555
}
@@ -102,7 +102,7 @@ function convertStyle(gd, trace) {
102102
return opts;
103103
}
104104

105-
function convertTextStyle(trace) {
105+
function convertTextStyle(trace, gd) {
106106
var count = trace._length;
107107
var textfontIn = trace.textfont;
108108
var textpositionIn = trace.textposition;
@@ -115,19 +115,20 @@ function convertTextStyle(trace) {
115115

116116
var texttemplate = trace.texttemplate;
117117
if(texttemplate) {
118+
var d3locale = gd._fullLayout._d3locale;
118119
optsOut.text = [];
119120
var pt;
120121
if(Array.isArray(texttemplate)) {
121122
for(i = 0; i < texttemplate.length; i++) {
122123
pt = {};
123124
appendArrayPointValue(pt, trace, i);
124-
optsOut.text.push(Lib.texttemplateString(texttemplate[i], pt, function() {}, pt));
125+
optsOut.text.push(Lib.texttemplateString(texttemplate[i], pt, d3locale, pt));
125126
}
126127
} else {
127128
for(i = 0; i < count; i++) {
128129
pt = {};
129130
appendArrayPointValue(pt, trace, i);
130-
optsOut.text.push(Lib.texttemplateString(texttemplate, pt, function() {}, pt));
131+
optsOut.text.push(Lib.texttemplateString(texttemplate, pt, d3locale, pt));
131132
}
132133
}
133134
} else {

0 commit comments

Comments
 (0)