I would like to use bokeh's TapTool
to open a different URL when clicking on each of some holoviews.Polygons
. An perfect example of how this works in bokeh is in the bokeh docs for point data. However, when I try to use it in holoviews, it doesn't seem to work.
The closest thing I could get to work is this:
import geoviews as gv
from bokeh.models import OpenURL, TapTool
url = 'https://google.@domain'
taptool = TapTool()
taptool.callback = OpenURL(url=url)
p = gv.Polygons(data, vdims=['Area', 'domain'], crs=ccrs.PlateCarree).options(alpha=1, tools=['hover', taptool])
p
The plot shows up nicely, and also the triggering of the URL opening works fine, however the parsing of the "@domain" doesn't work and the URL is "google.???" What is wrong here?
Not sure; seems to work when I do it for this nonsensical example:
import holoviews as hv, numpy as np
hv.extension("bokeh")
def rectangle(x=0, y=0, width=.05, height=.05):
return np.array([(x,y), (x+width, y), (x+width, y+height), (x, y+height)])
polys = hv.Polygons([{('x', 'y'): rectangle(x, y), 'level': z}
for x, y, z in np.random.rand(100, 3)], vdims='level')
url = 'https://google.@level'
taptool = TapTool()
taptool.callback = OpenURL(url=url)
polys.opts(color='level', line_width=1, tools=['hover', taptool])