Skip to content

Commit

Permalink
Add support for bokeh event callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 24, 2017
1 parent ed01c3c commit a5961ed
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def attributes_js(attributes, handles):
obj_name = attrs[0]
attr_getters = ''.join(["['{attr}']".format(attr=attr)
for attr in attrs[1:]])
if obj_name not in ['cb_obj', 'cb_data']:
if obj_name not in ['cb_obj', 'cb_data', 'event']:
assign_str = '{assign}{{id: {obj_name}["id"], value: {obj_name}{attr_getters}}};\n'.format(
assign=data_assign, obj_name=obj_name, attr_getters=attr_getters
)
Expand Down Expand Up @@ -169,6 +169,8 @@ class Callback(object):

_callbacks = {}

event = False

def __init__(self, plot, streams, source, **params):
self.plot = plot
self.streams = streams
Expand Down Expand Up @@ -274,6 +276,11 @@ def set_customjs(self, handle, references):
attributes = attributes_js(self.attributes, references)
code = 'var data = {};\n' + attributes + self.code + self_callback

if self.event:
js_callback = CustomJS(args=references, code=code)
handle.js_on_event(self.event, js_callback)
return

# Merge callbacks if another callback has already been attached
# otherwise set it
if id(handle.callback) in self._callbacks:
Expand Down

0 comments on commit a5961ed

Please sign in to comment.