将 Bokeh Glyph 变成 link
Turn Bokeh Glyph into a link
我想将某个情节上的所有散景字形转换为指向其他页面的链接。这可能吗?
例如,如果我有一张国家地图,每个国家作为一个补丁,如果用户点击一个国家,我想将他们重定向到该维基百科页面。
User's Guide中还有一个更简单的例子:
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)
我想将某个情节上的所有散景字形转换为指向其他页面的链接。这可能吗?
例如,如果我有一张国家地图,每个国家作为一个补丁,如果用户点击一个国家,我想将他们重定向到该维基百科页面。
User's Guide中还有一个更简单的例子:
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)