Skip to content

Commit 832a4f8

Browse files
authored
Merge pull request #1991 from plotly/test-mathjax
Test mathjax
2 parents 253eb24 + a7277c2 commit 832a4f8

File tree

3 files changed

+83
-5
lines changed

3 files changed

+83
-5
lines changed

Diff for: src/plot_api/plot_api.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Plotly.plot = function(gd, data, layout, config) {
107107
// any part of the plotting code can push to gd._promises, then
108108
// before we move to the next step, we check that they're all
109109
// complete, and empty out the promise list again.
110-
gd._promises = [];
110+
if(!Array.isArray(gd._promises)) gd._promises = [];
111111

112112
var graphWasEmpty = ((gd.data || []).length === 0 && Array.isArray(data));
113113

@@ -384,14 +384,16 @@ Plotly.plot = function(gd, data, layout, config) {
384384
drawData,
385385
finalDraw,
386386
initInteractions,
387-
Plots.rehover
387+
Plots.rehover,
388+
Plots.previousPromises
388389
];
389390

390-
Lib.syncOrAsync(seq, gd);
391-
392391
// even if everything we did was synchronous, return a promise
393392
// so that the caller doesn't care which route we took
394-
return Promise.all(gd._promises).then(function() {
393+
var plotDone = Lib.syncOrAsync(seq, gd);
394+
if(!plotDone || !plotDone.then) plotDone = Promise.resolve();
395+
396+
return plotDone.then(function() {
395397
gd.emit('plotly_afterplot');
396398
return gd;
397399
});

Diff for: test/image/baselines/mathjax.png

63.3 KB
Loading

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

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"data":[{
3+
"x": [0, 1],
4+
"y": [0, 1.414],
5+
"text": ["Hx+yH", "H\\sqrt{2}H"],
6+
"mode": "text+markers",
7+
"name": "HE^2=m^2c^4+p^2c^2H"
8+
}, {
9+
"x": [0, 1],
10+
"y": [1.4, 0.1],
11+
"text": ["H1.400 \\pm 0.023H", "H0.100 \\pm 0.002H"],
12+
"textposition": "auto",
13+
"type": "bar",
14+
"name": "Hx=\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}H"
15+
}, {
16+
"type": "pie",
17+
"values": [1, 9],
18+
"labels": ["H\\frac{1}{10}=10\\%H", "H\\frac{9}{10}=90\\%H"],
19+
"textinfo": "label",
20+
"domain": {"x": [0.3, 0.75], "y": [0.55, 1]}
21+
}, {
22+
"type": "heatmap",
23+
"z": [[1,2],[3,4]],
24+
"xaxis": "x2",
25+
"yaxis": "y2",
26+
"colorbar": {"title": "He^{i\\pi}=-1H", "y": 0.225, "len": 0.45}
27+
}],
28+
"layout": {
29+
"yaxis":{"domain": [0, 0.45], "title": "$y=\\sin{2 \\theta}$"},
30+
"xaxis":{
31+
"domain": [0, 0.45],
32+
"title": "$x=\\int_0^a a^2+1$",
33+
"tickvals": [0, 1],
34+
"ticktext": ["$\\frac{0}{100}$", "$\\frac{100}{100}$"]
35+
},
36+
"xaxis2": {"domain": [0.85, 1], "anchor": "y2"},
37+
"yaxis2": {
38+
"domain": [0, 0.45],
39+
"anchor": "x2",
40+
"tickvals": [0, 1],
41+
"ticktext": ["Ha+b+c+dH", "He+f+g+hH"],
42+
"title": "$(||01\\rangle+|10\\rangle)/\\sqrt2$"
43+
},
44+
"height":500,
45+
"width":800,
46+
"title": "$i\\hbar\\frac{d\\Psi}{dt}=-[V-\\frac{-\\hbar^2}{2m}\\nabla^2]\\Psi$",
47+
"annotations":[
48+
{
49+
"text": "H is substituted for $<br>where we would like<br>math but do not yet<br>fully support it",
50+
"xref": "paper", "yref": "paper",
51+
"x": 1.2, "xanchor": "left", "y": 0, "yanchor": "bottom",
52+
"showarrow": false
53+
},
54+
{
55+
"text":"$(top,left)$","showarrow":false,"xref":"paper","yref":"paper",
56+
"xanchor":"left","yanchor":"top","x":0,"y":1,"textangle":10,
57+
"bordercolor":"#0c0","borderpad":3,"bgcolor":"#dfd"
58+
},
59+
{
60+
"text":"$(right,bottom)$","xref":"paper","yref":"paper",
61+
"xanchor":"right","yanchor":"bottom","x":0.2,"y":0.7,"ax":-20,"ay":-20,
62+
"textangle":-30,"bordercolor":"#0c0","borderpad":3,"bgcolor":"#dfd",
63+
"opacity":0.5
64+
},
65+
{"text":"$not-visible$", "visible": false},
66+
{
67+
"text":"$^{29}Si$","x":0.7,"y":0.7,"showarrow":false,
68+
"xanchor":"right","yanchor":"top"
69+
},
70+
{
71+
"text":"$^{17}O$","x":0.7,"y":0.7,"ax":15,"ay":-15,
72+
"xanchor":"left","yanchor":"bottom"
73+
}
74+
]
75+
}
76+
}

0 commit comments

Comments
 (0)