python - Trouble embedding bokeh plot -
in working on flask website allow users plot data, decided use bokeh instead of matplotlib seems built embedding, ability use dynamic data. i've scoured online examples, , bokeh documentation. in examples see command 'create_html_snippet', supposed return snippet of html can inserted template:
from bokeh.plotting import * import numpy np # define function return html snippet. def build_plot(): # set output our plot. output_file('plot.html', title='plot') # create data our plot. x_data = np.arange(1, 101) y_data = np.random.randint(0, 101, 100) # create line plot our data. line(x_data, y_data) # create html snippet of our plot. snippet = curplot().create_html_snippet(embed_base_url='../static/js/', embed_save_loc='./static/js') # return snippet want place in our page. return snippet
i'm running code in conjunction main flask code below:
from flask import flask, render_template plots import build_plot app = flask(__name__) @app.route('/') # base url home page. def render_plot(): plot_snippet = build_plot() return plot_snippet if __name__ == "__main__": app.run(debug=true)
the "create_html_snippet" command not found in documentation, , anaconda version of python (created same people developing bokeh) gives following error:
attributeerror: 'plot' object has no attribute 'create_html_snippet'
it seems bokeh going through rapid development, , i'm wondering if deprecated. know current best way html snippet i'm looking for?
create_html_snippet
indeed deprecated. releasing bokeh 0.5 on july 7, there improved, simplified, , documented bokeh.embed
module supersedes function. if you'd try out sooner, there dev builds available now, instructions on mailing list:
https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/nvxeqdyy2eq
you can see new embed module (with complete docstrings) here:
https://github.com/continuumio/bokeh/blob/master/bokeh/embed.py
as nice flask embed example here:
https://github.com/continuumio/bokeh/tree/master/examples/embed
we don't yet have capability publish sphinx docs dev builds can check out markdown files new docs here:
https://github.com/continuumio/bokeh/blob/master/sphinx/source/docs/user_guide.rst#embedding
these getting expanded more give overview now.
edit: said, create_html_snippet
should still there, , functional, time being. if you'd file issue on gh can discuss or investigate more.
Comments
Post a Comment