Skip to content

Commit

Permalink
Fixed bokeh SideHistogram with (non)inverted axis
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jan 30, 2018
1 parent cbabb5b commit 458804a
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions holoviews/plotting/bokeh/chart.py
Expand Up @@ -365,16 +365,24 @@ class SideHistogramPlot(ColorbarPlot, HistogramPlot):
Whether to display the plot title.""")

default_tools = param.List(default=['save', 'pan', 'wheel_zoom',
'box_zoom', 'reset', 'ybox_select'],
'box_zoom', 'reset'],
doc="A list of plugin tools to use on the plot.")

_callback = """
color_mapper.low = cb_data['geometry']['y0'];
color_mapper.high = cb_data['geometry']['y1'];
source.change.emit()
main_source.change.emit()
color_mapper.low = cb_data['geometry']['{axis}0'];
color_mapper.high = cb_data['geometry']['{axis}1'];
source.change.emit(undefined)
main_source.change.emit(undefined)
"""

def __init__(self, *args, **kwargs):
super(SideHistogramPlot, self).__init__(*args, **kwargs)
if self.invert_axes:
self.default_tools.append('ybox_select')
else:
self.default_tools.append('xbox_select')


def get_data(self, element, ranges, style):
data, mapping, style = HistogramPlot.get_data(self, element, ranges, style)
color_dims = [d for d in self.adjoined.traverse(lambda x: x.handles.get('color_dim'))
Expand Down Expand Up @@ -407,11 +415,13 @@ def _init_glyph(self, plot, mapping, properties):
handles = {'color_mapper': self.handles['color_mapper'],
'source': self.handles['source'],
'main_source': main_source}
axis = 'y' if self.invert_axes else 'x'
callback = self._callback.format(axis=axis)
if box_select.callback:
box_select.callback.code += self._callback
box_select.callback.code += callback
box_select.callback.args.update(handles)
else:
box_select.callback = CustomJS(args=handles, code=self._callback)
box_select.callback = CustomJS(args=handles, code=callback)
return ret


Expand Down

0 comments on commit 458804a

Please sign in to comment.