我有下面的代码,它在(1.0,1.0)处绘制一个点。我希望能够单击此点打开由指定的url
属性指定的页面的浏览器:
from bokeh.plotting import figure
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource, TapTool, OpenURL
import pandas as pd
df = pd.DataFrame({"x": [1.0], "y": [1.0], "url": ["https://www.google.com"]})
datasource = ColumnDataSource(df)
fig = figure(
title='test',
plot_width=600,
plot_height=600,
tools=('pan, wheel_zoom, reset, tap')
)
p = fig.select(type=TapTool)
p.callback = OpenURL(url="@url")
fig.circle(
'x',
'y',
source=datasource,
line_alpha=0.6,
fill_alpha=0.6,
size=10
)
curdoc().add_root(fig)
但是,当我运行应用程序并单击该点时,一个新选项卡将打开http://localhost:5006/https%3A%2F%2Fwww.google.com
,这似乎表明bokeh想要打开相对于tornado服务器的URL。如何简单地打开绝对URL而不是相对URL
这是当前版本中的一个错误:
https://github.com/bokeh/bokeh/issues/11182
目前,您必须降级,或者等待下一个2.3.2点版本
(或者您也可以使用普通的
CustomJS
并构造自己对window.open
的调用)相关问题 更多 >
编程相关推荐