From 74f4e28d78da6704125535b525e05c8b057456bc Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 1 Sep 2020 23:08:59 +0200 Subject: [PATCH 1/2] Reset RangeXY when framewise is set --- holoviews/plotting/bokeh/element.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index dd4d494547..8b171d4d85 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -1420,11 +1420,25 @@ def _update_glyphs(self, element, ranges, style): self._update_datasource(source, data) + def _reset_ranges(self): + """ + Resets RangeXY streams if norm option is set to framewise + """ + if self.overlaid: + return + for el, stream in self.traverse(lambda x: (x.current_frame, x.streams)): + norm = self.lookup_options(el, 'norm').options + if norm.get('framewise'): + for s in self.streams: + if isinstance(s, RangeXY): + s.reset() + def update_frame(self, key, ranges=None, plot=None, element=None): """ Updates an existing plot with data corresponding to the key. """ + self._reset_ranges() reused = isinstance(self.hmap, DynamicMap) and (self.overlaid or self.batched) if not reused and element is None: element = self._get_frame(key) @@ -2302,6 +2316,7 @@ def update_frame(self, key, ranges=None, element=None): key tuple (where integers represent frames). Returns this state. """ + self._reset_ranges() reused = isinstance(self.hmap, DynamicMap) and self.overlaid if not reused and element is None: element = self._get_frame(key) From 82c32e458957b70e53c8cad27bd44f026a222366 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 1 Sep 2020 23:57:20 +0200 Subject: [PATCH 2/2] Test RangeXY stream reset --- holoviews/plotting/bokeh/element.py | 15 +++++++++------ holoviews/tests/plotting/bokeh/testcallbacks.py | 8 ++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index 8b171d4d85..567ddd173e 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -1426,12 +1426,15 @@ def _reset_ranges(self): """ if self.overlaid: return - for el, stream in self.traverse(lambda x: (x.current_frame, x.streams)): - norm = self.lookup_options(el, 'norm').options - if norm.get('framewise'): - for s in self.streams: - if isinstance(s, RangeXY): - s.reset() + for el, callbacks in self.traverse(lambda x: (x.current_frame, x.callbacks)): + if el is None: + continue + for callback in callbacks: + norm = self.lookup_options(el, 'norm').options + if norm.get('framewise'): + for s in callback.streams: + if isinstance(s, RangeXY): + s.reset() def update_frame(self, key, ranges=None, plot=None, element=None): """ diff --git a/holoviews/tests/plotting/bokeh/testcallbacks.py b/holoviews/tests/plotting/bokeh/testcallbacks.py index afdc03f9f3..9a9338cf74 100644 --- a/holoviews/tests/plotting/bokeh/testcallbacks.py +++ b/holoviews/tests/plotting/bokeh/testcallbacks.py @@ -474,6 +474,14 @@ def test_rangexy_datetime(self): self.assertEqual(stream.x_range[1], curve.iloc[3, 0]) self.assertEqual(stream.y_range, (0.2, 0.8)) + def test_rangexy_framewise_reset(self): + stream = RangeXY(x_range=(0, 2), y_range=(0, 1)) + curve = DynamicMap(lambda z, x_range, y_range: Curve([1, 2, z]), + kdims=['z'], streams=[stream]).redim.range(z=(0, 3)) + plot = bokeh_server_renderer.get_plot(curve.opts(framewise=True)) + plot.update((1,)) + self.assertEqual(stream.y_range, None) + class TestBokehCustomJSCallbacks(CallbackTestCase):