Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset RangeXY when framewise is set #4585

Merged
merged 2 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,11 +1420,28 @@ 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, 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):
"""
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)
Expand Down Expand Up @@ -2302,6 +2319,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)
Expand Down
8 changes: 8 additions & 0 deletions holoviews/tests/plotting/bokeh/testcallbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down