In the following MWE, clicking on a point of the scatter plot should show its index in the "debug" textbox. It does when the layout is scatter * dmap, it doesn’t when the layout is simply dmap. Indeed, scatter being the source of the Selection1D stream, its points are selected, not the points of the DynamicMap. Setting source=dmap doesn’t seem to help.
This is not satisfying because in my real use case I need the scatter plot to be updated after the first click (then a click on the second scatter plot to be registered), hence the DynamicMap.
How do I get rid of scatter in layout so that dmap is the actual source of events ?
import numpy as np
import holoviews as hv
import panel as pn
data = np.random.randn(100, 2)
scatter = hv.Scatter(
data
).opts(
tools = ["tap"]
)
debug = pn.widgets.TextInput(name="debug", value="")
def on_click(index):
if index is None:
return scatter
debug.value = str(index)
return scatter
stream = hv.streams.Selection1D(source=scatter)
dmap = hv.DynamicMap(on_click, streams=[stream])
#layout = scatter * dmap # works
layout = dmap # doesn’t work
pn.Column(
debug,
layout
)
I found my way out discarding DynamicMap :
No need for DynamicMap for my "switch plots" use case either thanks to
pn.bind: