在 Bokeh Python 散点图上打开 link 但不要立即关注 link

Open link on scatter plot in Bokeh Python but do not immediately follow link

我将散景模块与 Python 和以下示例一起使用:

from bokeh.models import ColumnDataSource, OpenURL, TapTool
from bokeh.plotting import figure, output_file, show

output_file("openurl.html")

p = figure(plot_width=400, plot_height=400,
           tools="tap", title="Click the Dots")

source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    color=["navy", "orange", "olive", "firebrick", "gold"]
    ))

p.circle('x', 'y', color='color', size=20, source=source)

url = "http://www.colors.commutercreative.com/@color/"
taptool = p.select(type=TapTool)
taptool.callback = OpenURL(url=url)

show(p)

一切正常,当我单击其中一个圆圈时,浏览器中会打开一个新选项卡,焦点会切换到该选项卡。

问题

但是,我感兴趣的是停留在绘图页面上,只是让新选项卡打开而不将焦点切换到该选项卡。

有人知道怎么做吗?我想这是 "OpenURL(...)".

的一些关键字参数

从 Bokeh 0.12 开始,没有配置选项。你绝对可以做一个自定义扩展来做到这一点,或者如果你想在核心库中看到它,它会成为一个优秀的小 PR 供新贡献者解决(我很乐意帮助你开始).无论如何,我都鼓励您将这个新功能请求提交给项目邮件列表或项目 GitHub 跟踪器。