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

[Tutorial Request] Flask Bootstrap + Multiple Bokeh plots #141

Open
ethen8181 opened this issue Oct 29, 2017 · 9 comments
Open

[Tutorial Request] Flask Bootstrap + Multiple Bokeh plots #141

ethen8181 opened this issue Oct 29, 2017 · 9 comments

Comments

@ethen8181
Copy link

Hi, Matt. Not sure if a tutorial request is allowed here. First of all, thanks for creating the Responsive Bar Charts with Bokeh, Flask and Python 3 tutorial, it was really insightful! I was wondering if you're planning to do a flask + flask_bootstrap and multiple bokeh plots tutorial ~ this is something that I would love to see ~~

@mattmakai
Copy link
Owner

hey @ethen8181, yea of course I love getting requests on here. I'm looking forward to doing more Bokeh tutorials but kinda waiting for the 1.0 release because so much of the API is changing and a lot of the code will have to be rewritten. Even the 0.12.5 to 0.12.6 release deprecated something I wrote in the Flask tutorial.

What would you like to see as far as Flask+Flask_bootstrap posts? Setting up and using it? Good practices for using a bootstrap-type library?

@ethen8181
Copy link
Author

ethen8181 commented Oct 30, 2017

Good to know! I am looking for a how to embed multiple Bokeh plots in Flask (using flask_bootstrap) post, not so much on the how to set up flask or use flask_bootstrap.

I had a go at it by modifying your tutorial, and managed to get 1 Bokeh plot on there, but failed to get multiple bokeh plots to work. So thought you might had experience doing related things.

@mattmakai
Copy link
Owner

hmm I don't have time to check this out myself right now but did you double the line script, div = components(plot) so it was separated into unique variables for the script and div for 2 separate plots? did it just not display or give a certain error message?

@ethen8181
Copy link
Author

Yeah, so I tried the following:

# p1 is a single plot, and this renders fine
plot_script, plot_div = components(p1)

# but when I tried to add multiple plots it just gives me a blank screen

# 1. gridplot doesn't work
# https://bokeh.pydata.org/en/latest/docs/user_guide/layout.html#grids-layout-for-plots
grid = gridplot([[p1, p2], [p3, p4]])
plot_script, plot_div = components(grid)

# 2. passing multiple plots to components also didn't work
# https://bokeh.pydata.org/en/latest/docs/user_guide/embed.html#components
plot_script, plot_div = components((p1, p2, p3, p4))

# 3. looping through components and then embedding all individual script and div
plot_divs = []
plot_scripts = []
for p in (p1, p2, p3, p4):
     plot_script, plot_div = components(p)
     plot_divs.append(plot_div)
     plot_scripts.append(plot_script)

The problem is there's no error message, it's just no plots would show up ...

@mattmakai
Copy link
Owner

unfortunately I looked through my Bokeh projects and haven't had to put multiple plots on a single page so I haven't had this issue. if I have time I'd love to give it a try but for a faster response it's worth dropping a note to the Bokeh devs (https://github.com/bokeh/bokeh) with your attempts and the lack of documentation around what seems like it would be a straightforward bit to code

@ethen8181
Copy link
Author

Gotcha, thanks ~~

@martinh85
Copy link

Hello,

hmm I don't have time to check this out myself right now but did you double the line script, div = components(plot) so it was separated into unique variables for the script and div for 2 separate plots? did it just not display or give a certain error message?

Hello Matt,
have you found the solution how to handle multiple plots on same page?
https://stackoverflow.com/questions/54734169/bokeh-django-embedding-more-independent-plots-via-components

@mattmakai
Copy link
Owner

sorry @martinh85, I have not had time to look into it further. Bokeh has evolved a lot since I wrote this post so at some point I'll need to completely refactor what's in it to keep it up to date

@martinh85
Copy link

sorry @martinh85, I have not had time to look into it further. Bokeh has evolved a lot since I wrote this post so at some point I'll need to completely refactor what's in it to keep it up to date

thanks anyway Matt

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