-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Test mathjax #1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test mathjax #1991
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the crux of the issue: if you have more than one async item in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Solid investigation work 🔬 🎉 🥇 Is this enough to close #76 you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think so! |
||
var plotDone = Lib.syncOrAsync(seq, gd); | ||
if(!plotDone || !plotDone.then) plotDone = Promise.resolve(); | ||
|
||
return plotDone.then(function() { | ||
gd.emit('plotly_afterplot'); | ||
return gd; | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 $<br>where we would like<br>math but do not yet<br>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" | ||
} | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I didn't write a test for... but I made this change so that if you make a plot, then change it before its promises have finished, you should still wait for them (via
previousPromises
) so you don't get a race condition between them and the new plot (with the old ones potentially overwriting elements of the new plot you made).I haven't actually managed to cause any ill effects without this change in manual testing, but I think it's safer this way.