Skip to content
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

Blank plot in html using nbconvert (basic template) #1033

Open
ltetrel opened this issue Jun 14, 2018 · 6 comments
Open

Blank plot in html using nbconvert (basic template) #1033

ltetrel opened this issue Jun 14, 2018 · 6 comments
Labels

Comments

@ltetrel
Copy link

@ltetrel ltetrel commented Jun 14, 2018

Hi everyone,

I know that to convert a jupyter notebook (.ipynb) to an html I can use this command :

jupyter nbconvert --to html --template full myNotebook.ipynb

In this case I can successfully see my plot in the resulting html (myNotebook_full.html in
myNotebook.zip).

However, when I am trying to convert it using the basic template, there is a blank space instead of the plot

(myNotebook_basic.html in myNotebook.zip).

jupyter nbconvert --to html --template basic myNotebook.ipynb

missing

Do you have an idea why ?

Thanks all for your work and support !

@ltetrel

This comment has been minimized.

Copy link
Author

@ltetrel ltetrel commented Jul 6, 2018

I finally managed to resolve my issue.
I just needed to include the following scripts at the top of my .html template file :

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
@Juanlu001

This comment has been minimized.

Copy link
Contributor

@Juanlu001 Juanlu001 commented Sep 12, 2018

For Sphinx docs that use themes without jQuery on <head>, this workaround is fragile and does not always work in all browsers or all the times. We are tracking it accross several places:

spatialaudio/nbsphinx#128, poliastro/poliastro#281, readthedocs/readthedocs.org#4367

Perhaps this is something that could be worked on the Plotly side? Could we please reopen this?

@jonmmease

This comment has been minimized.

Copy link
Member

@jonmmease jonmmease commented Sep 12, 2018

Hi @Juanlu001, sure we can reopen this.

So it looks to me like the JavaScript block emitted by plotly.py on init_notebook_mode expects requirejs to be active, but I don't see how it's using or altering jquery.

script_inject = (
''
'<script type=\'text/javascript\'>'
'if(!window.Plotly){{'
'define(\'plotly\', function(require, exports, module) {{'
'{script}'
'}});'
'require([\'plotly\'], function(Plotly) {{'
'window.Plotly = Plotly;'
'}});'
'}}'
'</script>'
'').format(script=get_plotlyjs())

Could you summarize your current understanding of what's going wrong?

Another approach would be to use the fact the FigureWidget is an ipywidget. I've successfully embedded FigureWidget instances for nbviewer, and it's supposed to be possible in sphinx as well (https://ipywidgets.readthedocs.io/en/stable/embedding.html) though I haven't tried that yet.

@jonmmease jonmmease reopened this Sep 12, 2018
@jonmmease jonmmease added the question label Sep 12, 2018
@Juanlu001

This comment has been minimized.

Copy link
Contributor

@Juanlu001 Juanlu001 commented Sep 23, 2018

Could you summarize your current understanding of what's going wrong?

Yes! Please read my comment here:

readthedocs/readthedocs.org#4367 (comment)

@jonmmease

This comment has been minimized.

Copy link
Member

@jonmmease jonmmease commented Oct 24, 2018

Hi @Juanlu001, just following up. I haven't studied the thread in detail, but it seems like folks are making progress on the RTD side. Is there anything you see at this point that you need from plotly.py?

@Juanlu001

This comment has been minimized.

Copy link
Contributor

@Juanlu001 Juanlu001 commented Oct 24, 2018

@jonmmease Thanks! Progress is slow but I think it's been acknowledged that it's an issue on the RTD side - let's hope someone gives it the final push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.