Reputation: 57281
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.
Upvotes: 3
Views: 7331
Reputation: 34568
There also a simpler example in the 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)
Upvotes: 5