Skip to content

Commit

Permalink
Fix updates to Overlay with variable items (#3701)
Browse files Browse the repository at this point in the history
* Fix updates to Overlay with variable items

* Add test
  • Loading branch information
philippjfr authored May 16, 2019
1 parent 5dbf69a commit 5612e7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
20 changes: 10 additions & 10 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,16 +2130,16 @@ def update_frame(self, key, ranges=None, element=None):
if element is not None:
ranges = self.compute_ranges(range_obj, key, ranges)

# Update plot options
plot_opts = self.lookup_options(element, 'plot').options
inherited = self._traverse_options(element, 'plot',
self._propagate_options,
defaults=False)
plot_opts.update(**{k: v[0] for k, v in inherited.items() if k not in plot_opts})
self.param.set_param(**plot_opts)

if element and not self.overlaid and not self.tabs and not self.batched:
self._update_ranges(element, ranges)
# Update plot options
plot_opts = self.lookup_options(element, 'plot').options
inherited = self._traverse_options(element, 'plot',
self._propagate_options,
defaults=False)
plot_opts.update(**{k: v[0] for k, v in inherited.items() if k not in plot_opts})
self.param.set_param(**plot_opts)

if not self.overlaid and not self.tabs and not self.batched:
self._update_ranges(element, ranges)

# Determine which stream (if any) triggered the update
triggering = [stream for stream in self.streams if stream._triggering]
Expand Down
10 changes: 10 additions & 0 deletions holoviews/tests/plotting/bokeh/testoverlayplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from holoviews.core import NdOverlay, HoloMap, DynamicMap, Overlay
from holoviews.core.options import Cycle
from holoviews.element import Curve, Points, ErrorBars, Text, VLine
from holoviews.streams import Stream
from holoviews.util import Dynamic

from .testplot import TestBokehPlot, bokeh_renderer
Expand Down Expand Up @@ -278,3 +279,12 @@ def test_dynamicmap_legend_updates_add_dynamic_plots(self):
legend_labels = [item.label for item in plot.state.legend[0].items]
self.assertEqual(legend_labels, [{'value': 'A'}, {'value': 'B'}, {'value': 'C'}])

def test_dynamicmap_ndoverlay_shrink_number_of_items(self):
selected = Stream.define('selected', items=3)()
def callback(items):
return NdOverlay({j: Overlay([Curve([1, 2, j])]) for j in range(items)})
dmap = DynamicMap(callback, streams=[selected])
plot = bokeh_renderer.get_plot(dmap)
selected.event(items=2)
self.assertEqual(len([r for r in plot.state.renderers if r.visible]), 2)

0 comments on commit 5612e7e

Please sign in to comment.