Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure CDSCallback also handles patch events on source #3594

Merged
merged 3 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def set_customjs_callback(self, js_callback, handle):
if self.on_events:
for event in self.on_events:
handle.js_on_event(event, js_callback)
elif self.on_changes:
if self.on_changes:
for change in self.on_changes:
handle.js_on_change(change, js_callback)
elif hasattr(handle, 'callback'):
Expand Down Expand Up @@ -389,8 +389,11 @@ def set_server_callback(self, handle):
if self.on_events:
for event in self.on_events:
handle.on_event(event, self.on_event)
elif self.on_changes:
if self.on_changes:
for change in self.on_changes:
if change in ['patching', 'streaming']:
# Patch and stream events do not need handling on server
continue
handle.on_change(change, self.on_change)


Expand Down Expand Up @@ -912,7 +915,7 @@ class CDSCallback(Callback):

attributes = {'data': 'source.data'}
models = ['source']
on_changes = ['data']
on_changes = ['data', 'patching']

def initialize(self, plot_id=None):
super(CDSCallback, self).initialize(plot_id)
Expand Down
12 changes: 8 additions & 4 deletions holoviews/tests/plotting/bokeh/testcallbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def test_point_draw_callback_initialized_js(self):
points = Points([(0, 1)])
PointDraw(source=points)
plot = bokeh_renderer.get_plot(points)
cb = plot.callbacks[0].callbacks[0]
self.assertEqual(plot.handles['source'].js_property_callbacks,
{'change:data': [plot.callbacks[0].callbacks[0]]})
{'change:data': [cb], 'patching': [cb]})

def test_point_draw_callback_with_vdims_initialization(self):
points = Points([(0, 1, 'A')], vdims=['A'])
Expand Down Expand Up @@ -221,8 +222,9 @@ def test_poly_draw_callback_initialized_js(self):
polys = Polygons([[(0, 0), (2, 2), (4, 0)]])
PolyDraw(source=polys)
plot = bokeh_renderer.get_plot(polys)
cb = plot.callbacks[0].callbacks[0]
self.assertEqual(plot.handles['source'].js_property_callbacks,
{'change:data': [plot.callbacks[0].callbacks[0]]})
{'change:data': [cb], 'patching': [cb]})

def test_poly_draw_callback_with_vdims(self):
polys = Polygons([{'x': [0, 2, 4], 'y': [0, 2, 0], 'A': 1}], vdims=['A'])
Expand Down Expand Up @@ -272,8 +274,9 @@ def test_box_edit_callback_initialized_js(self):
boxes = Polygons([Box(0, 0, 1)])
BoxEdit(source=boxes)
plot = bokeh_renderer.get_plot(boxes)
cb = plot.callbacks[0].callbacks[0]
self.assertEqual(plot.handles['rect_source'].js_property_callbacks,
{'change:data': [plot.callbacks[0].callbacks[0]]})
{'change:data': [cb], 'patching': [cb]})

def test_poly_edit_callback(self):
polys = Polygons([[(0, 0), (2, 2), (4, 0)]])
Expand All @@ -297,8 +300,9 @@ def test_poly_edit_callback_initialized_js(self):
polys = Polygons([[(0, 0), (2, 2), (4, 0)]])
PolyEdit(source=polys)
plot = bokeh_renderer.get_plot(polys)
cb = plot.callbacks[0].callbacks[0]
self.assertEqual(plot.handles['source'].js_property_callbacks,
{'change:data': [plot.callbacks[0].callbacks[0]]})
{'change:data': [cb], 'patching': [cb]})

def test_poly_edit_shared_callback(self):
polys = Polygons([[(0, 0), (2, 2), (4, 0)]])
Expand Down