Skip to content

Commit

Permalink
Fixed empty NdOverlay on initialization in batched mode
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 5, 2016
1 parent e4ffb41 commit ca9533d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions holoviews/plotting/bokeh/annotation.py
Expand Up @@ -44,6 +44,8 @@ class LineAnnotationPlot(ElementPlot):

_update_handles = ['glyph']

_plot_methods = dict(single='Span')

def get_data(self, element, ranges=None, empty=False):
data, mapping = {}, {}
mapping['dimension'] = 'width' if isinstance(element, HLine) else 'height'
Expand Down
7 changes: 5 additions & 2 deletions holoviews/plotting/bokeh/element.py
Expand Up @@ -539,7 +539,10 @@ def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
Initializes a new plot object with the last available frame.
"""
# Get element key and ranges for frame
element = self.hmap.last
if self.batched:
element = [el for el in self.hmap.data.values() if len(el)][-1]
else:
element = self.hmap.last
key = self.keys[-1]
ranges = self.compute_ranges(self.hmap, key, ranges)
self.current_ranges = ranges
Expand Down Expand Up @@ -1010,7 +1013,7 @@ def _init_tools(self, element, callbacks=[]):

def initialize_plot(self, ranges=None, plot=None, plots=None):
key = self.keys[-1]
element = self._get_frame(key)
element = [el for el in self.hmap.data.values() if len(el)][-1]
ranges = self.compute_ranges(self.hmap, key, ranges)
if plot is None and not self.tabs and not self.batched:
plot = self._init_plot(key, element, ranges=ranges, plots=plots)
Expand Down
6 changes: 3 additions & 3 deletions holoviews/plotting/plot.py
Expand Up @@ -559,8 +559,8 @@ def __init__(self, element, keys=None, ranges=None, dimensions=None,
self.hmap = element

plot_element = self.hmap.last
if self.batched:
plot_element = plot_element.last
if self.batched and not isinstance(self, GenericOverlayPlot):
plot_element = [el for el in plot_element if len(el) > 0][-1]

top_level = keys is None
if top_level:
Expand Down Expand Up @@ -851,7 +851,7 @@ def _create_subplots(self, ranges):

if issubclass(plottype, GenericOverlayPlot):
opts['show_legend'] = self.show_legend
elif self.batched:
elif self.batched and 'batched' in plottype._plot_methods:
opts['batched'] = self.batched
if len(ordering) > self.legend_limit:
opts['show_legend'] = False
Expand Down

0 comments on commit ca9533d

Please sign in to comment.