Skip to content

Commit

Permalink
Small fixes for updating bokeh plots
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jun 21, 2016
1 parent ff9091b commit f154159
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions holoviews/plotting/bokeh/util.py
Expand Up @@ -164,8 +164,7 @@ def compute_static_patch(document, models):
attributes and will break if new models have been added since
the plot was first created.
"""
json = document.to_json()
references = refs(json)
references = refs(document.to_json())
requested_updates = [m.ref['id'] for m in models]

value_refs = {}
Expand Down
15 changes: 5 additions & 10 deletions holoviews/plotting/bokeh/widgets.py
Expand Up @@ -7,7 +7,7 @@
from bokeh.util.notebook import get_comms

from ..widgets import NdWidget, SelectionWidget, ScrubberWidget

from .util import compute_static_patch

class BokehWidget(NdWidget):

Expand Down Expand Up @@ -41,22 +41,17 @@ def _plot_figure(self, idx, fig_format='json'):
html = self.renderer.html(self.plot, fig_format)
return html
else:
doc = self.plot.document
if hasattr(doc, 'last_comms_handle'):
handle = doc.last_comms_handle
else:
handle = _CommsHandle(get_comms(doc.last_comms_target),
doc, doc.to_json())
doc.last_comms_handle = handle

to_json = doc.to_json()
if handle.doc is not doc:
msg = dict(doc=to_json)
else:
msg = Document._compute_patch_between_json(handle.json, to_json)
if isinstance(handle._json, dict):
handle._json[doc] = to_json
else:
handle._json = to_json
plotobjects = [h for handles in self.plot.traverse(lambda x: x.current_handles)
for h in handles]
msg = compute_static_patch(doc, plotobjects)
handle.comms.send(json.dumps(msg))
return 'Complete'

Expand Down

0 comments on commit f154159

Please sign in to comment.