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

How to embed plotly visualizations without RequireJS #2371

Closed
choldgraf opened this issue Apr 10, 2020 · 9 comments
Closed

How to embed plotly visualizations without RequireJS #2371

choldgraf opened this issue Apr 10, 2020 · 9 comments

Comments

@choldgraf
Copy link
Contributor

Hey there - I work on a project called Jupyter Book that lets people share collections of notebooks as a static website.

I'm working on a page for interactive visualization libraries, and I am having a hard time getting Plotly to work. I believe that the reason for this is our SSG uses Bootstrap, and RequireJS (needed by the plotly renderer) doesn't easily work with Bootstrap.

Are there guidelines for displaying interactive plotly graphs in HTML without RequireJS? Or, suggestions for how to get RequreJS to work with Bootstrap that could be added to the docs? Given how common Bootstrap is, perhaps this is something that could benefit others as well (e.g. I know the new pydata-sphinx-theme also uses Bootstrap, so plotly viz won't work there either)

@emmanuelle
Copy link
Contributor

Hi @choldgraf ! Could you please share a link explaining how RequireJS and bootstrap are incompatible?

@choldgraf
Copy link
Contributor Author

Here's an issue where it's been discussed in the pydata theme:

pydata/pydata-sphinx-theme#30

There are also lots of stack overflow posts like this:

https://stackoverflow.com/questions/16259098/cant-load-bootstrap-with-requirejs

and blog posts like this:

http://blog.chasepeeler.com/2017/09/12/bootstrap-4-and-requirejs/

so, it seems that it is possible, but complicated. That's why I was wondering if there is a recommended practice for plotly

@nicolaskruchten
Copy link
Contributor

Hmm, so we're running Bootstrap on our doc site and loading things up with RequireJS and it seems to work OK: https://plotly.com/python/getting-started/

@nicolaskruchten
Copy link
Contributor

(That's not to say you're not having a problem and that we won't help you fix it! Just pointing to one case where it works :)

@choldgraf
Copy link
Contributor Author

Oh that is very helpful actually haha... If we can get bootstrap working using requirejs that would be great. Do you know if the site needed any particular configuration that was abnormal?

@choldgraf
Copy link
Contributor Author

OK so I think I figured it out - basically the issue with Bootstrap is in the order in which you load bootstrap.js before or after require.js. I'll close this...though I'm definitely still interested in learning about best-practices here. We'd like the Jupyter Book project to have good support for plotly, and I am a bit concerned that this issue will pop up again in some form or another.

In case you're curious, here's the page where plotly isn't working. I think that this PR to the pydata theme will fix it but 🤷‍♂️

@nicolaskruchten
Copy link
Contributor

Ah, nice, I'm glad you figured this out... sorry, it was a long weekend and I was trying to stay away from Github :) I'm not surprised that there's a load-order sensitivity there but I'm glad there's a path forward!

@nicolaskruchten
Copy link
Contributor

Our whole doc site is built using Jupytext/nbconvert to make HTML fragments that are then stitched together using Jekyll... The nbconvert bit relies on RequireJS and the Jekyll bit is styled with Bootstrap. We use Jekyll because the same CMS contains docs for Javascript and R, and each language's docs are in some idiomatic format that we needed to glue together somehow :)

@choldgraf
Copy link
Contributor Author

choldgraf commented Apr 14, 2020

nice, thanks for the explanation :-) we were using Jekyll in the Jupyter Book project as well, though we're moving to Sphinx to make it easier for things like references across pages etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants