Skip to content

Instantly share code, notes, and snippets.

@macloo
Created September 26, 2019 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macloo/f5eba0218d7f7b368d316f891ecc7f50 to your computer and use it in GitHub Desktop.
Save macloo/f5eba0218d7f7b368d316f891ecc7f50 to your computer and use it in GitHub Desktop.
Export HTML and JavaScript of a Bokeh chart
# assumes you already made a chart with Bokeh and it is assigned to a variable, chart1
# added code for exporting the chart as HTML + JS
# https://bokeh.pydata.org/en/latest/docs/user_guide/embed.html
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import file_html
# create a complete HTML file
html = file_html(chart1, CDN, "bokeh_chart01")
# regular python to write the file
newfile = open('bokeh_chart01.html', 'w')
newfile.write(html)
newfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment