Reputation: 1609
I wrote a small app for visualising some data. The app is a small web application in Flask and I would like to serve bokeh components in the response page. Something like:
script, div = components(figure)
return render_template('plot.html', div_plot=div, script_plot=script)
This approach would seems to work for simple charts or figures like the example below, where I can create the plot using the attribute in the figure object. Something like
fig = figure(plot_width=900, plot_height=200, tools=tools,x_axis_type='datetime')
fig.line('date', 't1', source=source_static)
script, div = components(fig)
With a Donut object unfortunately it seems that things works differently, You can create a Donut object only like this
pie_chart = Donut(data)
show(pie_chart)
How do I get the div and scripts from a Donut? how do I embed it in a existing html page?
Upvotes: 1
Views: 92
Reputation: 1609
I found the solution myself in the end. Apparently it is not necessary to go through a 'figure' object. Instead, one could just do
from bokeh.charts import Donut
import pandas as pd
data = pd.Series( ... some data ... )
script, div = components(Donut(data))
Silly me. Hope this will help someone.
Upvotes: 1