Skip to content

Commit e381c25

Browse files
committed
Merge branch 'texttemplate-meta' into texttemplate
2 parents 2528aa6 + 4b1face commit e381c25

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/traces/scattergl/convert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ function convertTextStyle(trace, gd) {
122122
for(i = 0; i < Math.min(texttemplate.length, count); i++) {
123123
pt = {};
124124
appendArrayPointValue(pt, trace, i);
125-
optsOut.text.push(Lib.texttemplateString(texttemplate[i], pt, d3locale, pt));
125+
optsOut.text.push(Lib.texttemplateString(texttemplate[i], pt, d3locale, pt, trace._meta || {}));
126126
}
127127
} else {
128128
for(i = 0; i < count; i++) {
129129
pt = {};
130130
appendArrayPointValue(pt, trace, i);
131-
optsOut.text.push(Lib.texttemplateString(texttemplate, pt, d3locale, pt));
131+
optsOut.text.push(Lib.texttemplateString(texttemplate, pt, d3locale, pt, trace._meta || {}));
132132
}
133133
}
134134
} else {

test/jasmine/assets/check_texttemplate.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
2222
expect(gd._fullData[0].textinfo).toBe(undefined);
2323
});
2424

25-
// Generate customdata
25+
2626
var N = tests[0][1].length;
27+
var i;
28+
29+
// Generate customdata
2730
var customdata = [];
28-
for(var i = 0; i < N; i++) {
31+
for(i = 0; i < N; i++) {
2932
customdata.push(Lib.randstr({}));
3033
}
3134
mock[0].customdata = customdata;
3235
tests.push(['%{customdata}', customdata]);
3336

37+
// Generate meta
38+
mock[0].meta = {'colname': 'A'};
39+
var metaSolution = [];
40+
for(i = 0; i < N; i++) {
41+
metaSolution.push(mock[0].meta.colname);
42+
}
43+
tests.push(['%{meta.colname}', metaSolution]);
44+
3445
if(isGL) {
3546
tests.forEach(function(test) {
3647
it('@gl should support texttemplate', function(done) {

0 commit comments

Comments
 (0)