-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Make offline embedded <div> plots responsive. #717
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
Conversation
This PR enables responsiveness in offline plots, where `output_type = 'div'` and not just if `output_type = 'file'`. I've been making use of [Django-JET](https://github.com/geex-arts/django-jet) dashboard widget plugins in order to embed a Plotly graph. Before this change I would have to reload the page every time I resized the browser window in order to make the plot resize to the new sizes.
I'm gently bumping, so maintainers get to notice this, this PR is only a one line of code patch, I await for peer review, please let me know if there is anything else that needs to be done in order to guarantee responsiveness of the plots. C.C. @cldougl, @chriddyp, @Kully as you seem to be recently active as maintainers of plotly.py Thanks in advance! |
thanks for tagging me @Ismael-VC ! This looks good to me, I can't think of any blockers. @cldougl @Kully any blockers from you? |
@Ismael-VC Yeah, no blockers for me either. Very clearly laid out with the before and after pictures. 👍 from me (can I💃 this @chriddyp?) |
💃 |
@Kully can you update the changelog as well when you merge? |
|
Tank you very much guys! :) |
I'll be wanting to make use of this functionality, thanks @Ismael-VC! This may not be the appropriate place to ask, but all offline plots I make, even with
Is there something I'm missing here? |
This PR enables responsiveness in offline plots, when
output_type == 'div'
by adding theresize_script
to the return value ofplotly.offline.plot
, just as it is done ifoutput_type == 'file'
, as seen here:I've been making use of Django-JET dashboard widget plugins in order to embed a Plotly graph, before this change I would have to reload the page manually every time I resized the browser window in order to make the plot resize to the new size of the
django-jet
widget containing it (which is responsive).Before this change
As you can see, plot is truncated.
After this change
Now it resizes properly.
This is the code I used to test.
In
dashboard_modules.py
:In
graph.html
:Related issue: Responsive plots