简体   繁体   中英

Need example embedding plot with bokeh

Could anybody give me a brief example of how to use bokeh's embed tool? I've had a little bit of luck with the create_html_snippet() but I need a method that will support the use of hovertool for a barchart. I want absolute basics if possible, just any example or anything.

My situation:

  1. novice at Javascript (do I need to do an import statement in my html?)
  2. novice at html (haven't made a site for years)
  3. still pretty beginner with bokeh too.
  4. not running bokeh server, just want to embed static html like I receive from the save() method.

EDIT: none of the resources I found were super helpful but for others who stumble upon this this might help.

bokeh.embed.autoload_static(plot_object=myplot, resources=Resources('cdn'), script_path='embed.js)

This returns 2 items the first goes in that embed.js file. The second goes straight onto your html.

As you said in your comment, we have a new Bokeh embed API since 0.5 release.

You can see some embedding examples here:

https://github.com/bokeh/bokeh/tree/master/examples/embed

And you have here a little bit of docs about embedding:

https://docs.bokeh.org/en/latest/docs/user_guide/embed.html

Let's know if you need additional help to work on this...

I've just stumbled upon the deprecated create_html_snippet myself, after updating to the new bokeh and breaking my code. After going through the docs about embedding I managed to get it to work again, and here 'sa simple example code which works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM