在散景图中嵌入散景图和数据表

时间:2016-02-09 17:11:22

标签: python flask bokeh

我正在尝试使用Bokeh文档中提供的一些示例,在一个烧瓶生成的网站(同一页面)中嵌入散景图和散景数据表。两个组件都是独立运行的。我试图通过gridplot将它们放在一起,但这似乎只适用于绘图,而数据表是一个'小部件'。 我可能错过了一些非常基本的概念,但是赞赏任何指针或示例的链接

1 个答案:

答案 0 :(得分:5)

我喜欢这样做的方法是使用embed.components方法的全部功能并传入一个绘图对象的字典,然后在我的html模板中的任何地方渲染它们。

我按如下方式调用组件:

from bokeh.embed import components
script, div_dict = components({"plot": plot, "table": table})

我的div_dict看起来像这样:

# {"plot": plot_div, "table": table_div})

然后我将这个dict和脚本传递到我的模板上下文中并使用它:

<body>
   {{ plot_div }}
   {{ table_div }}
   {{ script }}
</body>

以下是散景示例中的示例:https://github.com/bokeh/bokeh/blob/master/examples/embed/embed_multiple_responsive.py#L26