如何将后端的全息视图与 bokehjs 前端连接起来

How to connect holoviews in backend with bokehjs frontend

你好,我正在开发一个需要绘制数百万个点的网页,所以我在后端使用 HoloViews生成一个图并将其作为 Bokeh 模型发送到我使用 Bokehjs[=29= 的前端].

所以在 API 中我调用了一个执行此操作的函数

hv.extension("bokeh")
points = hv.Points(df)
datashaded = hd.datashade(points, aggregator=ds.count_cat('cat')).redim.range(x=(-5,5),y=(-5,5))
plot = hv.render(datashaded)
return json.dumps(json_item(plot))

和 returns 以 JSON 格式发送到前端的 Bokeh 模型。

函数 hd.datashade 渲染散景图并在您控制缩放时在内部调用数据着色器来创建图像。但问题是,当我通过 API 调用此函数一次时,缩放控件不会创建新图像,而只会使像素变大。

我需要一种方法让 "live python process running" 成为 documentation 状态,这样我就可以拥有缩放控件和工具提示。但我不知道如何实现。

一旦将内容转储到 JSON,就不再与 Python 代码有任何联系。相反,您可以执行 http://pyviz.org/tutorial/13_Deploying_Bokeh_Apps.html:

中的操作
hv.extension("bokeh")
points = hv.Points(df)
datashaded = hd.datashade(points, aggregator=ds.count_cat('cat')).redim.range(x=(-5,5),y=(-5,5))
doc = hv.renderer('bokeh').server_doc(datashaded)
doc.title = 'HoloViews Bokeh App'

然后 运行 bokeh serve --show file.py 在您的文件上启动 Bokeh Server。 Bokeh 服务器将确保 Python 进程正在 运行ning,提供用于显示您的 HTML/JS 的网络服务器,并在它们之间建立连接。