Skip to content

Commit 9677929

Browse files
committed
texttemplate: fix GL traces with txt array longer than data
1 parent 7bb3379 commit 9677929

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Diff for: src/traces/scatter3d/convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function convertPlotlyOptions(scene, data) {
246246
var d3locale = scene.fullLayout._d3locale;
247247
if(Array.isArray(data.texttemplate)) {
248248
text = new Array(data.texttemplate.length);
249-
for(i = 0; i < data.texttemplate.length; i++) {
249+
for(i = 0; i < Math.min(len, data.texttemplate.length); i++) {
250250
var pt = {};
251251
pt.text = text[i];
252252
appendArrayPointValue(pt, data, i);

Diff for: src/traces/scattergl/convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function convertTextStyle(trace, gd) {
119119
optsOut.text = [];
120120
var pt;
121121
if(Array.isArray(texttemplate)) {
122-
for(i = 0; i < texttemplate.length; i++) {
122+
for(i = 0; i < Math.min(texttemplate.length, count); i++) {
123123
pt = {};
124124
appendArrayPointValue(pt, trace, i);
125125
optsOut.text.push(Lib.texttemplateString(texttemplate[i], pt, d3locale, pt));

Diff for: test/image/mocks/gl2d_texttemplate.json

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
"xaxis": "x2",
1212
"yaxis": "y2"
1313
}, {
14+
"type": "scattergl",
15+
"mode": "markers+text",
16+
"x": [3, 2, 1, 0],
17+
"y": [0, 1, 4, 9],
18+
"text": ["1", "2", "3"],
19+
"textposition": "top center",
20+
"xaxis": "x2",
21+
"yaxis": "y2"
22+
},{
1423
"type": "scatterpolargl",
1524
"mode": "markers+text",
1625
"text": ["A", "B", "C", "D"],

0 commit comments

Comments
 (0)