在烧瓶中嵌入散景图和数据表
Embedding bokeh plot and datatable in flask
我正在尝试使用 Bokeh 文档中提供的一些示例在烧瓶生成的网站(同一页面)中嵌入散景图和散景数据表。这两个组件都是独立工作的。我试图通过 gridplot 将它们放在一起,但这似乎只适用于绘图,数据表是 'widget'。
我可能遗漏了一些非常基本的概念,但是任何指向示例的指针或链接都非常感谢
我喜欢这样做的方式是使用 embed.components
方法的全部功能并传入绘图对象的字典,然后在我的 html 模板中需要的任何地方渲染它们。
我调用组件如下:
from bokeh.embed import components
script, div_dict = components({"plot": plot, "table": table})
我的 div_dict
看起来像这样:
# {"plot": plot_div, "table": table_div})
然后我将这个字典和脚本传递到我的模板上下文中并像这样使用它:
<body>
{{ plot_div }}
{{ table_div }}
{{ script }}
</body>
这是散景示例中的一个示例:https://github.com/bokeh/bokeh/blob/master/examples/embed/embed_multiple_responsive.py#L26
我正在尝试使用 Bokeh 文档中提供的一些示例在烧瓶生成的网站(同一页面)中嵌入散景图和散景数据表。这两个组件都是独立工作的。我试图通过 gridplot 将它们放在一起,但这似乎只适用于绘图,数据表是 'widget'。 我可能遗漏了一些非常基本的概念,但是任何指向示例的指针或链接都非常感谢
我喜欢这样做的方式是使用 embed.components
方法的全部功能并传入绘图对象的字典,然后在我的 html 模板中需要的任何地方渲染它们。
我调用组件如下:
from bokeh.embed import components
script, div_dict = components({"plot": plot, "table": table})
我的 div_dict
看起来像这样:
# {"plot": plot_div, "table": table_div})
然后我将这个字典和脚本传递到我的模板上下文中并像这样使用它:
<body>
{{ plot_div }}
{{ table_div }}
{{ script }}
</body>
这是散景示例中的一个示例:https://github.com/bokeh/bokeh/blob/master/examples/embed/embed_multiple_responsive.py#L26