Skip to content

Commit 11ea019

Browse files
committed
Merge branch 'texttemplate-split' into texttemplate
2 parents cbbcfcb + 6729286 commit 11ea019

6 files changed

+102
-211
lines changed
25.5 KB
Loading
Loading
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"data": [{
3+
"type": "scattergl",
4+
"mode": "markers+text",
5+
"x": [0, 1, 2, 3],
6+
"y": [0, 1, 4, 9],
7+
8+
"text": ["a", "b", "c", "d"],
9+
"texttemplate": "%{text}: (%{x}, %{y})",
10+
"textposition": "top center",
11+
"xaxis": "x2",
12+
"yaxis": "y2"
13+
}, {
14+
"type": "scatterpolargl",
15+
"mode": "markers+text",
16+
"text": ["A", "B", "C", "D"],
17+
"texttemplate": "%{text}: (%{r:0.2f},%{theta:0.2f})",
18+
"textposition": "top center",
19+
"r": [1, 0.5, 1, 1.5],
20+
"theta": [0, 90, 180, 270],
21+
"showgrid": false,
22+
"subplot": "polar"
23+
}
24+
],
25+
"layout": {
26+
"showlegend": false,
27+
"width": 600,
28+
"height": 300,
29+
"margin": {
30+
"t": 50,
31+
"b": 50,
32+
"l": 50,
33+
"r": 50
34+
},
35+
"polar": {
36+
"radialaxis": {
37+
"showline": false,
38+
"linewidth": 0,
39+
"tickwidth": 2,
40+
"gridcolor": "white",
41+
"gridwidth": 0
42+
}
43+
},
44+
"grid": {
45+
"rows": 1,
46+
"columns": 2,
47+
"pattern": "independent",
48+
"xgap": 5,
49+
"ygap": 5
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"data": [{
3+
"type": "scatter3d",
4+
"x": [0, 1, 2],
5+
"y": [0, 2, 1],
6+
"z": [-5, -2, 4],
7+
"text": ["A", "B", "C"],
8+
"texttemplate": "%{text}: (%{x}, %{y}, %{z})",
9+
"mode": "markers+text"
10+
}],
11+
"layout": {
12+
"width": 400,
13+
"height": 400,
14+
"margin": {"t": 20, "l": 0, "r": 0, "b": 0}
15+
}
16+
}

test/image/mocks/texttemplate_2.json

-193
This file was deleted.

test/jasmine/assets/check_texttemplate.js

+34-18
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
3131
mock[0].customdata = customdata;
3232
tests.push(['%{customdata}', customdata]);
3333

34-
tests.forEach(function(test) {
35-
it(isGL ? '@gl' : '' + 'should support texttemplate', function(done) {
36-
var gd = createGraphDiv();
37-
var mockCopy = Lib.extendDeep(mock, {});
38-
mockCopy[0].texttemplate = test[0];
39-
Plotly.newPlot(gd, mockCopy)
40-
.then(function() {
41-
if(isGL) {
34+
if(isGL) {
35+
tests.forEach(function(test) {
36+
it('@gl should support texttemplate', function(done) {
37+
var gd = createGraphDiv();
38+
var mockCopy = Lib.extendDeep(mock, {});
39+
mockCopy[0].texttemplate = test[0];
40+
Plotly.newPlot(gd, mockCopy)
41+
.then(function() {
4242
var glText;
4343
if(isPolar) {
4444
glText = gd._fullLayout.polar._subplot._scene.glText;
@@ -54,20 +54,36 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
5454
var text = glText[0].text.slice(from, to);
5555
expect(text).toEqual(test[1][i]);
5656
}
57-
} else {
57+
})
58+
.catch(failTest)
59+
.finally(function() {
60+
Plotly.purge(gd);
61+
destroyGraphDiv();
62+
})
63+
.then(done);
64+
});
65+
});
66+
} else {
67+
tests.forEach(function(test) {
68+
it('should support texttemplate', function(done) {
69+
var gd = createGraphDiv();
70+
var mockCopy = Lib.extendDeep(mock, {});
71+
mockCopy[0].texttemplate = test[0];
72+
Plotly.newPlot(gd, mockCopy)
73+
.then(function() {
5874
var pts = Plotly.d3.selectAll(selector);
5975
expect(pts.size()).toBe(test[1].length);
6076
pts.each(function() {
6177
expect(test[1]).toContain(Plotly.d3.select(this).text());
6278
});
63-
}
64-
})
65-
.catch(failTest)
66-
.finally(function() {
67-
Plotly.purge(gd);
68-
destroyGraphDiv();
69-
})
70-
.then(done);
79+
})
80+
.catch(failTest)
81+
.finally(function() {
82+
Plotly.purge(gd);
83+
destroyGraphDiv();
84+
})
85+
.then(done);
86+
});
7187
});
72-
});
88+
}
7389
};

0 commit comments

Comments
 (0)