Skip to content

Commit

Permalink
Correct handling of batched multi_line and patches options
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 3, 2017
1 parent 9738625 commit c9c3e68
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions holoviews/plotting/bokeh/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,9 @@ def get_batched_data(self, overlay, ranges=None, empty=False):
data[sanitized].append([k])
data = {opt: vals for opt, vals in data.items()
if not any(v is None for v in vals)}
return data, dict(xs=elmapping['x'], ys=elmapping['y'],
**{o: o for o in opts if o in data})
mapping = {{'x': 'xs', 'y': 'ys'}.get(k, k): v
for k, v in elmapping.items()}
return data, mapping


class AreaPlot(PolygonPlot):
Expand Down
6 changes: 3 additions & 3 deletions holoviews/plotting/bokeh/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def get_batched_data(self, element, ranges=None, empty=False):
# Apply static styles
style = styles[zorder]
expand_batched_style(style, self._batched_style_opts,
data, elmapping)
data, elmapping, path=True)

return data, elmapping


Expand Down Expand Up @@ -110,7 +111,6 @@ def get_batched_data(self, element, ranges=None, empty=False):
# Apply static styles
style = styles[zorder]
expand_batched_style(style, self._batched_style_opts,
data, elmapping)

data, elmapping, path=True)

return data, elmapping
10 changes: 6 additions & 4 deletions holoviews/plotting/bokeh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,15 @@ def get_tab_title(key, frame, overlay):
return title


def expand_batched_style(style, opts, data, mapping):
def expand_batched_style(style, opts, data, mapping, path=False):
"""
Expands styles applied to a batched plot by iterating over the
supplied list of style options and any options found in the supplied
style dictionary to the ColumnDataSource data and mapping.
style dictionary to the ColumnDataSource data and mapping. Supply
path=True to avoid nesting style options as required by multi_line
and patches glyphs.
"""
nvals = len(list(data.values()[0])[-1])
nvals = int(path) or len(list(data.values()[0])[-1])
for opt in opts:
if 'color' in opt:
alias = 'color'
Expand Down Expand Up @@ -583,4 +585,4 @@ def expand_batched_style(style, opts, data, mapping):
mapping[opt] = {'field': opt}
if 'color' in opt and isinstance(val, tuple):
val = rgb2hex(val)
data[opt].append([val]*nvals)
data[opt].append(val if path else [val]*nvals)

0 comments on commit c9c3e68

Please sign in to comment.