diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index a6a4a62f9f1..c8619163454 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -107,7 +107,7 @@ Plotly.plot = function(gd, data, layout, config) { // any part of the plotting code can push to gd._promises, then // before we move to the next step, we check that they're all // complete, and empty out the promise list again. - gd._promises = []; + if(!Array.isArray(gd._promises)) gd._promises = []; var graphWasEmpty = ((gd.data || []).length === 0 && Array.isArray(data)); @@ -384,14 +384,16 @@ Plotly.plot = function(gd, data, layout, config) { drawData, finalDraw, initInteractions, - Plots.rehover + Plots.rehover, + Plots.previousPromises ]; - Lib.syncOrAsync(seq, gd); - // even if everything we did was synchronous, return a promise // so that the caller doesn't care which route we took - return Promise.all(gd._promises).then(function() { + var plotDone = Lib.syncOrAsync(seq, gd); + if(!plotDone || !plotDone.then) plotDone = Promise.resolve(); + + return plotDone.then(function() { gd.emit('plotly_afterplot'); return gd; }); diff --git a/test/image/baselines/mathjax.png b/test/image/baselines/mathjax.png new file mode 100644 index 00000000000..95f086468c5 Binary files /dev/null and b/test/image/baselines/mathjax.png differ diff --git a/test/image/mocks/mathjax.json b/test/image/mocks/mathjax.json new file mode 100644 index 00000000000..743b2100570 --- /dev/null +++ b/test/image/mocks/mathjax.json @@ -0,0 +1,76 @@ +{ + "data":[{ + "x": [0, 1], + "y": [0, 1.414], + "text": ["Hx+yH", "H\\sqrt{2}H"], + "mode": "text+markers", + "name": "HE^2=m^2c^4+p^2c^2H" + }, { + "x": [0, 1], + "y": [1.4, 0.1], + "text": ["H1.400 \\pm 0.023H", "H0.100 \\pm 0.002H"], + "textposition": "auto", + "type": "bar", + "name": "Hx=\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}H" + }, { + "type": "pie", + "values": [1, 9], + "labels": ["H\\frac{1}{10}=10\\%H", "H\\frac{9}{10}=90\\%H"], + "textinfo": "label", + "domain": {"x": [0.3, 0.75], "y": [0.55, 1]} + }, { + "type": "heatmap", + "z": [[1,2],[3,4]], + "xaxis": "x2", + "yaxis": "y2", + "colorbar": {"title": "He^{i\\pi}=-1H", "y": 0.225, "len": 0.45} + }], + "layout": { + "yaxis":{"domain": [0, 0.45], "title": "$y=\\sin{2 \\theta}$"}, + "xaxis":{ + "domain": [0, 0.45], + "title": "$x=\\int_0^a a^2+1$", + "tickvals": [0, 1], + "ticktext": ["$\\frac{0}{100}$", "$\\frac{100}{100}$"] + }, + "xaxis2": {"domain": [0.85, 1], "anchor": "y2"}, + "yaxis2": { + "domain": [0, 0.45], + "anchor": "x2", + "tickvals": [0, 1], + "ticktext": ["Ha+b+c+dH", "He+f+g+hH"], + "title": "$(||01\\rangle+|10\\rangle)/\\sqrt2$" + }, + "height":500, + "width":800, + "title": "$i\\hbar\\frac{d\\Psi}{dt}=-[V-\\frac{-\\hbar^2}{2m}\\nabla^2]\\Psi$", + "annotations":[ + { + "text": "H is substituted for $
where we would like
math but do not yet
fully support it", + "xref": "paper", "yref": "paper", + "x": 1.2, "xanchor": "left", "y": 0, "yanchor": "bottom", + "showarrow": false + }, + { + "text":"$(top,left)$","showarrow":false,"xref":"paper","yref":"paper", + "xanchor":"left","yanchor":"top","x":0,"y":1,"textangle":10, + "bordercolor":"#0c0","borderpad":3,"bgcolor":"#dfd" + }, + { + "text":"$(right,bottom)$","xref":"paper","yref":"paper", + "xanchor":"right","yanchor":"bottom","x":0.2,"y":0.7,"ax":-20,"ay":-20, + "textangle":-30,"bordercolor":"#0c0","borderpad":3,"bgcolor":"#dfd", + "opacity":0.5 + }, + {"text":"$not-visible$", "visible": false}, + { + "text":"$^{29}Si$","x":0.7,"y":0.7,"showarrow":false, + "xanchor":"right","yanchor":"top" + }, + { + "text":"$^{17}O$","x":0.7,"y":0.7,"ax":15,"ay":-15, + "xanchor":"left","yanchor":"bottom" + } + ] + } +}