I am using streams.Selection1D but am getting too many updates while user is still selecting points (while using lasso tool). I see a throttle on callbacks but am not sure how to pass the throttle or throttle_timeout keywords to the stream Selection1D class . There is Selection1DCallback but not sure how it is related and can be used like Selection1D.
Any suggestions ?
I am asking myself the same question.
Is there a general way to throttle (bokeh tools based) callbacks globally, like panel supports it ?
I think you can check event.final
holoviz:main
← holoviz:popups
opened 07:14AM - 03 Apr 24 UTC
This PR exposes the ability to pop up floating panes added in Bokeh 3.4 after a … selection is made. The contents of the popup can be added to the `Stream` and will be populated when the user makes the first selection. The contents can be any Panel object or any component that can be rendered with Panel. To control the visibility of the popup this PR currently links the `visible` parameter of the provided component to the visibility of the popup itself.
Here's a simple example adding three distinct forms to each type of supported stream:
```python
points = hv.Points(np.random.randn(1000, 2))
def form(name):
text_input = pn.widgets.TextInput(name='Description')
button = pn.widgets.Button(name='Save', on_click=lambda _: layout.param.update(visible=False))
layout = pn.Column(f'# {name}', text_input, button)
return layout
hv.streams.BoundsXY(source=points, popup=form('Bounds'))
hv.streams.Lasso(source=points, popup=form('Lasso'))
hv.streams.Tap(source=points, popup=form('Tap'))
points.opts(tools=['box_select', 'lasso_select', 'tap'], width=600, height=600, size=6, color='black', fill_color=None)
```
![floating_panel](https://github.com/holoviz/holoviews/assets/1550771/35c499ed-6582-449d-a7d2-f461789ba265)
- [x] Decide whether the `visible` approach is sensible
- [x] Ensure this works on the server
- [x] Add documentation
- [x] Add tests
Thank you for that link @ahuang11 .
My actual implementation for that usecase does not pass/use the event
argument directly. It is something like this MRVE:
import holoviews as hv
from holoviews.streams import Selection1D
import numpy as np
hv.extension('bokeh')
def some_func(index):
print(f"Selected indices are {index}")
dmap = hv.DynamicMap(lambda: hv.Points(np.random.rand(10, 2))).opts(tools=["lasso_select"])
selection_stream = Selection1D(source=dmap)
selection_stream.add_subscriber(some_func)
dmap
As the example shows, the stream delivers the selected indices continuously as soon as the lasso_select tool catches a Point.
Do I have access to event.final
inside some_func
so I can process the input only when a lasso selection has finished?
You may have to use js_on_event
holoviz:main
← holoviz:popups
opened 07:14AM - 03 Apr 24 UTC
This PR exposes the ability to pop up floating panes added in Bokeh 3.4 after a … selection is made. The contents of the popup can be added to the `Stream` and will be populated when the user makes the first selection. The contents can be any Panel object or any component that can be rendered with Panel. To control the visibility of the popup this PR currently links the `visible` parameter of the provided component to the visibility of the popup itself.
Here's a simple example adding three distinct forms to each type of supported stream:
```python
points = hv.Points(np.random.randn(1000, 2))
def form(name):
text_input = pn.widgets.TextInput(name='Description')
button = pn.widgets.Button(name='Save', on_click=lambda _: layout.param.update(visible=False))
layout = pn.Column(f'# {name}', text_input, button)
return layout
hv.streams.BoundsXY(source=points, popup=form('Bounds'))
hv.streams.Lasso(source=points, popup=form('Lasso'))
hv.streams.Tap(source=points, popup=form('Tap'))
points.opts(tools=['box_select', 'lasso_select', 'tap'], width=600, height=600, size=6, color='black', fill_color=None)
```
![floating_panel](https://github.com/holoviz/holoviews/assets/1550771/35c499ed-6582-449d-a7d2-f461789ba265)
- [x] Decide whether the `visible` approach is sensible
- [x] Ensure this works on the server
- [x] Add documentation
- [x] Add tests
May I ask you to provide an example or a pointer to a resource? I haven’t worked with js_on_event yet.
In the link above, I think there’s an example. You can get plot
by doing hv.renderer("bokeh").get_plot()
I think