本文介绍了将Bokeh Glyph变成链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将某个绘图上的所有Bokeh字形都转换成指向其他页面的链接.这可能吗?
I would like to turn all of the Bokeh glyphs on a certain plot into links to other pages. Is this possible?
例如,如果我有一张国家/地区地图,则每个国家/地区都是一个补丁,如果用户单击某个国家/地区,我希望将其重定向到该维基百科页面.
For example if I had a map of countries, each country as a patch, if a user were to click on a country I would like to redirect them to that wikipedia page.
推荐答案
用户指南:
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)
这篇关于将Bokeh Glyph变成链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!