Problematic hv.streams.RangeXY with DynamicMap

Hi,

I am expecting to call update_plot_range function when I use Box Zoom. But I can’t.

import holoviews as hv
import param
import panel as pn

hv.extension('bokeh')

class RangeUpdatePlot(param.Parameterized):
    x = param.Number(default=0)
    y = param.Number(default=0)
    width = param.Integer(default=1050)
    height = param.Integer(default=700)

    def __init__(self, **params):
        super().__init__(**params)
        self.points = hv.Points([(1, 2), (3, 4), (5, 6)])
        self.range_stream = hv.streams.RangeXY()
        self.plot = hv.DynamicMap(
            lambda: self.points.opts(plot=dict(active_tools=['box_zoom'])),
            streams=[self.range_stream],
        )
        self.range_stream.param.watch(self.update_plot_range, ['x_range', 'y_range'])

    def update_plot_range(self, *events):
        print("*****")
        for event in events:
            plot = event.obj
            plot.update(bounds=(self.range_stream.x_range, self.range_stream.y_range))

    def view(self):
        return pn.panel(self.plot.opts(width=self.width, height=self.height))

app = RangeUpdatePlot()
app.view().servable()

it says "… raise Exception(prefix + ’ cannot accept any stream parameters’)
Exception: DynamicMaps using generators (or callables without arguments) cannot accept any stream parameters "

Just at a quick glance, I don’t think you are using hooks correctly.

thank you for your interest I changed the code and remove hooks .