LS
I searched for this topic but I didn’t find it, so sorry if I missed it.
I want to embed a plot on a (web2py) page.
I want to get the script and div.
I only get these after I do bar_plot.show() or I get the error "AttributeError: Bar object has no attribute ‘chart’.
This opens a new browser tab and I don’t need that.
Some time ago I read about this but I can’t find it anymore.
The code is like:
import bokeh as bokeh
from bokeh.charts import Bar
iata_bar = Bar(df_iata_plot, filename=“iata_bar.html”)
iata_bar.show()
#iata_bar_script, iata_bar_div = bokeh.embed.components(iata_bar.chart.plot , bokeh.resources.CDN)
#iata_bar_html = bokeh.embed.components(iata_bar.chart.plot , bokeh.resources.CDN)
iata_bar_html = bokeh.embed.file_html(iata_bar.chart.plot , bokeh.resources.CDN, “ASR-IATA”)
``
How can I get the script and div without the show() ?
Thanks, keep up the good work !
Arthur
Hi Arthur,
The current bokeh.charts implementation does support what you need but requires a bit of machinery. You can the solution here: https://github.com/bokeh/bokeh/issues/1528 and here: https://github.com/bokeh/bokeh/issues/1549
You just need to:
from bokeh.charts import _charts
and patch it with:
#patch the default view method to not show the original chart
_charts.view = lambda x: x
This will get better and easier with the next releases.
Thanks
Fabio
···
On Monday, December 29, 2014 9:54:16 PM UTC+1, Arthur Dijkstra wrote:
LS
I searched for this topic but I didn’t find it, so sorry if I missed it.
I want to embed a plot on a (web2py) page.
I want to get the script and div.
I only get these after I do bar_plot.show() or I get the error "AttributeError: Bar object has no attribute ‘chart’.
This opens a new browser tab and I don’t need that.
Some time ago I read about this but I can’t find it anymore.
The code is like:
import bokeh as bokeh
from bokeh.charts import Bar
iata_bar = Bar(df_iata_plot, filename=“iata_bar.html”)
iata_bar.show()
#iata_bar_script, iata_bar_div = bokeh.embed.components(iata_bar.chart.plot , bokeh.resources.CDN)
#iata_bar_html = bokeh.embed.components(iata_bar.chart.plot , bokeh.resources.CDN)
iata_bar_html = bokeh.embed.file_html(iata_bar.chart.plot , bokeh.resources.CDN, “ASR-IATA”)
``
How can I get the script and div without the show() ?
Thanks, keep up the good work !
Arthur
Thanks, that works, great support !