Skip to content

Plotly plots show locally but not on RTD #4367

Closed
@astrojuanlu

Description

@astrojuanlu

Details

Expected Result

I expected the Plotly plots to show in RTD the same way as locally.

Actual Result

Because of readthedocs/sphinx_rtd_theme#328, I am using a hack, which is adding require.js at the top of the page from a notebook cell:

from IPython.display import HTML
HTML('<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>')

https://juanlu-poliastro.readthedocs.io/en/latest/examples/Visualizing%20the%20SpaceX%20Tesla%20Roadster%20trip%20to%20Mars.html

I tried to build locally and the result is correctly seen in Firefox and Chrome.

When deploying to RTD, on Firefox this gives several JavaScript ReferenceErrors but the plot loads. These errors come from RTD scripts:

ReferenceError: _ is not defined  # doctools.js:15
ReferenceError: $ is not defined  # readthedocs-doc-embed.js:1
ReferenceError: jQuery is not defined  # Visualizing the SpaceX Tesla Roadster trip to Mars.html:681

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):

HTML('''
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
''')

https://juanlu-poliastro.readthedocs.io/en/latest/examples/Plotting%20in%203D.html

Then I get errors coming from require.js and the plot doesn't load in Firefox nor Chrome.

Metadata

Metadata

Assignees

Labels

SupportSupport question

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions