Join GitHub today
Plotly plots show locally but not on RTD #4367
I expected the Plotly plots to show in RTD the same way as locally.
Because of rtfd/sphinx_rtd_theme#328, I am using a hack, which is adding
I tried to build locally and the result is correctly seen in Firefox and Chrome.
In Chrome, on the other hand, I get similar errors but the plot never loads.
When I try to add jQuery as suggested in plotly/plotly.py#1033 (comment):
Then I get errors coming from
This was referenced
Jul 13, 2018
I do see the plots in Firefox 61.0.1 (64-bits) on Linux Arch even with the errors that are shown in the Firefox console. On the other hand in Chrome it works, does not work, crashes my Chrome and behaves in a crazy way
We will need to research more about this, but I can tell that after refreshing a couple of times the page from Chrome Versión 61.0.3163.79 (Build oficial) (64 bits) (with and without cache) I was able to see the graph:
I'd say that there is something that depends on the order of loading those js libraries...
I'm not sure how to continue debugging this, though.
referenced this issue
Sep 12, 2018
I created a repo with a much simpler test case to display the buggy behavior:
There are two branches (one with the RTD theme and one with Alabaster) and five notebooks that display four different combinations + an interactive widget.
I still did not have time to test what @Blendify started in rtfd/sphinx_rtd_theme#545, but the fact that Alabaster does not show display this behavior would indicate that there it's a RTD + RTD theme specific behavior.
My current workarounds are:
I acknowledge that we have to conceal expectations and settle on who should handle this, so can we try to reach an agreement?
As to fixing the underlying issue, that will be done here:
Until then, try the workaround documented here:
In general, you get better performance by loading JS at the end of the page rather than in the head as loading JS blocks rendering until it is fetched. However, no other Sphinx theme seems to care about that performance so I guess the RTD theme won't either.
I see that error here: https://rtd-js-test.readthedocs.io/en/latest/Connected%20-%20require.js%20Hack.html
Glad to know rtfd/sphinx_rtd_theme#545 is still under consideration, I was worried because the branch is lagging a bit behind :) The problem with the workaround is that it's not that easy to modify the output of nbsphinx, as it's not a
In #4787 (comment) I encountered the same problem. I fixed it by (copy from that issue):
def remove_jquery_and_underscore(app): # We need to remove the jquery and underscore file that are # added by default because we already add it in the <head> tag. remove = lambda x: not any(js in x for js in ['jquery', 'underscore']) if hasattr(app.builder, 'script_files'): app.builder.script_files = [x for x in app.builder.script_files if remove(x)] def setup(app): app.connect('builder-inited', remove_jquery_and_underscore)
Using my setup I am able to correctly show plotly plots, for example https://adaptive.readthedocs.io/en/latest/docs.html#adaptive-learnernd.
No JS errors whatsoever, all the plots work. It would be great to have this in