Skip to content

Commit 02a4cad

Browse files
committed
Add fallback to calls to texttemplateString
1 parent 336e9ae commit 02a4cad

File tree

9 files changed

+65
-20
lines changed

9 files changed

+65
-20
lines changed

src/components/drawing/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,13 @@ drawing.textPointStyle = function (s, trace, gd) {
12991299
var labels = fn ? fn(d, trace, fullLayout) : {};
13001300
var pointValues = {};
13011301
appendArrayPointValue(pointValues, trace, d.i);
1302-
var meta = trace._meta || {};
1303-
text = Lib.texttemplateString(text, labels, fullLayout._d3locale, pointValues, d, meta);
1302+
text = Lib.texttemplateString({
1303+
args: [pointValues, d, trace._meta],
1304+
d3locale: fullLayout._d3locale,
1305+
fallback: trace.texttemplatefallback,
1306+
labels,
1307+
string: text
1308+
});
13041309
}
13051310

13061311
var pos = d.tp || trace.textposition;

src/traces/bar/plot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,13 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) {
10731073

10741074
var customdata = Lib.castOption(trace, cdi.i, 'customdata');
10751075
if (customdata) obj.customdata = customdata;
1076-
return Lib.texttemplateString(texttemplate, obj, fullLayout._d3locale, pt, obj, trace._meta || {});
1076+
return Lib.texttemplateString({
1077+
args: [pt, obj, trace._meta],
1078+
d3locale: fullLayout._d3locale,
1079+
fallback: trace.texttemplatefallback,
1080+
labels: obj,
1081+
string: texttemplate
1082+
});
10771083
}
10781084

10791085
function calcTextinfo(cd, index, xa, ya) {

src/traces/heatmap/plot.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,13 @@ module.exports = function (gd, plotinfo, cdheatmaps, heatmapLayer) {
450450
if (theText === undefined || theText === false) theText = '';
451451
obj.text = theText;
452452

453-
var _t = Lib.texttemplateString(
454-
texttemplate,
455-
obj,
456-
gd._fullLayout._d3locale,
457-
obj,
458-
trace._meta || {}
459-
);
453+
var _t = Lib.texttemplateString({
454+
args: [obj, trace._meta],
455+
d3locale: gd._fullLayout._d3locale,
456+
fallback: trace.texttemplatefallback,
457+
labels: obj,
458+
string: texttemplate
459+
});
460460
if (!_t) continue;
461461

462462
var lines = _t.split('<br>');

src/traces/pie/plot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,13 @@ function formatSliceLabel(gd, pt, cd0) {
12711271
var obj = makeTemplateVariables(pt);
12721272
var ptTx = helpers.getFirstFilled(trace.text, pt.pts);
12731273
if (isValidTextValue(ptTx) || ptTx === '') obj.text = ptTx;
1274-
pt.text = Lib.texttemplateString(txt, obj, gd._fullLayout._d3locale, obj, trace._meta || {});
1274+
pt.text = Lib.texttemplateString({
1275+
args: [obj, trace._meta],
1276+
d3locale: gd._fullLayout._d3locale,
1277+
fallback: trace.texttemplatefallback,
1278+
labels: obj,
1279+
string: txt
1280+
});
12751281
}
12761282
}
12771283
}

src/traces/scatter3d/convert.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,13 @@ function convertPlotlyOptions(scene, data) {
257257
};
258258
var pointValues = {};
259259
appendArrayPointValue(pointValues, data, i);
260-
var meta = data._meta || {};
261-
text[i] = Lib.texttemplateString(txt(i), labels, d3locale, pointValues, d, meta);
260+
text[i] = Lib.texttemplateString({
261+
args: [pointValues, d, data._meta],
262+
d3locale,
263+
fallback: data.texttemplatefallback,
264+
labels,
265+
string: txt(i)
266+
});
262267
}
263268
}
264269

src/traces/scattergl/convert.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,15 @@ function convertTextStyle(gd, trace) {
141141
var labels = trace._module.formatLabels(d, trace, fullLayout);
142142
var pointValues = {};
143143
appendArrayPointValue(pointValues, trace, i);
144-
var meta = trace._meta || {};
145-
optsOut.text.push(Lib.texttemplateString(txt(i), labels, d3locale, pointValues, d, meta));
144+
optsOut.text.push(
145+
Lib.texttemplateString({
146+
args: [pointValues, d, trace._meta],
147+
d3locale,
148+
fallback: trace.texttemplatefallback,
149+
labels,
150+
string: txt(i)
151+
})
152+
);
146153
}
147154
} else {
148155
if (isArrayOrTypedArray(trace.text) && trace.text.length < count) {

src/traces/scattermap/convert.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,13 @@ function makeSymbolGeoJSON(calcTrace, gd) {
300300
var labels = trace._module.formatLabels(calcPt, trace, fullLayout);
301301
var pointValues = {};
302302
appendArrayPointValue(pointValues, trace, calcPt.i);
303-
var meta = trace._meta || {};
304-
text = Lib.texttemplateString(tt, labels, fullLayout._d3locale, pointValues, calcPt, meta);
303+
text = Lib.texttemplateString({
304+
args: [pointValues, calcPt, trace._meta],
305+
d3locale: fullLayout._d3locale,
306+
fallback: trace.texttemplatefallback,
307+
labels,
308+
string: tt
309+
});
305310
} else {
306311
text = fillText(i);
307312
}

src/traces/scattermapbox/convert.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,13 @@ function makeSymbolGeoJSON(calcTrace, gd) {
300300
var labels = trace._module.formatLabels(calcPt, trace, fullLayout);
301301
var pointValues = {};
302302
appendArrayPointValue(pointValues, trace, calcPt.i);
303-
var meta = trace._meta || {};
304-
text = Lib.texttemplateString(tt, labels, fullLayout._d3locale, pointValues, calcPt, meta);
303+
text = Lib.texttemplateString({
304+
args: [pointValues, calcPt, trace._meta],
305+
d3locale: fullLayout._d3locale,
306+
fallback: trace.texttemplatefallback,
307+
labels,
308+
string: tt
309+
});
305310
} else {
306311
text = fillText(i);
307312
}

src/traces/sunburst/plot.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,13 @@ exports.formatSliceLabel = function (pt, entry, trace, cd, fullLayout) {
632632
var ptTx = Lib.castOption(trace, cdi.i, 'text');
633633
if (Lib.isValidTextValue(ptTx) || ptTx === '') obj.text = ptTx;
634634
obj.customdata = Lib.castOption(trace, cdi.i, 'customdata');
635-
return Lib.texttemplateString(txt, obj, fullLayout._d3locale, obj, trace._meta || {});
635+
return Lib.texttemplateString({
636+
args: [obj, trace._meta],
637+
d3locale: fullLayout._d3locale,
638+
fallback: trace.texttemplatefallback,
639+
labels: obj,
640+
string: txt
641+
});
636642
};
637643

638644
function getInscribedRadiusFraction(pt) {

0 commit comments

Comments
 (0)