Displaying Bokeh Crossfilter Example

时光怂恿深爱的人放手 提交于 2019-12-13 07:24:59

问题


I dowloaded the repository for Bokeh Crossfilter example from here:

https://github.com/bokeh/bokeh/tree/master/examples/app/crossfilter

It is supposed to generate the interactive plot displayed here:

https://demo.bokeh.org/crossfilter

I ran main.py in the repository. However, nothing appeared. Then I realized the code does not show the layout. So I added the line show(layout) in the end, which did indeed display the layout on a web browser but it would not update the plot when I select different things for x and y axes. I do realize that show(layout) code only shows whatever the layout was at the moment of running the code and it is not telling it to update. However, I couldn't figure out how to show this plot on a web browser so that it is still interactive (would update the plot when I select different axes on the browser).

I would much appreciate any help. Thank you!


回答1:


http://docs.bokeh.org/en/latest/docs/gallery.html In the gallery you can see the first section of examples fall under the bokeh server app category, and require a bokeh server to work interactively.

The second section of examples are standalone (in the browser only).

To run the app corectly: download all the contents of the folder, and save them in the folder, say crossfilter. Open up the command prompt (not in python) and type bokeh serve --show crossfilter. This will open up the app and it should respond to user interaction.

There is a key difference in what can be achieved in running show(layout) from python, and serving a bokeh app from the command line.

Using show(...) will display the content within the browser, from here there is no connection between python and the browser, and therefore no way to update plots from python functions. It can only use javascript (which runs within the browser). There are no javascript callbacks within the crossfilter example, and therefore nothing will happen when you interact with anything.

Bokeh provides a server functionality, which allows code to be run from python and update plots on user interaction. Start from here: http://docs.bokeh.org/en/latest/docs/user_guide/server.html



来源:https://stackoverflow.com/questions/44729057/displaying-bokeh-crossfilter-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!