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

Made BokehRenderer.server_doc method more general #1486

Merged
merged 1 commit into from
May 29, 2017
Merged
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
17 changes: 12 additions & 5 deletions holoviews/plotting/bokeh/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get_widget(self_or_cls, plot, widget_type, doc=None, **kwargs):
def app(self_or_cls, plot, show=False, new_window=False):
"""
Creates a bokeh app from a HoloViews object or plot. By
default simply uses attaches plot to bokeh's curdoc and
default simply attaches the plot to bokeh's curdoc and
returns the Document, if show option is supplied creates
an Application instance and displays it either in a browser
window or inline if notebook extension has been loaded.
Expand Down Expand Up @@ -162,18 +162,25 @@ def show_callback():
return server


def server_doc(self, plot, doc=None):
@bothmethod
def server_doc(self_or_cls, obj, doc=None):
"""
Get server document.
Get a bokeh Document with the plot attached. May supply
an existing doc, otherwise bokeh.io.curdoc() is used to
attach the plot to the global document instance.
"""
if doc is None:
doc = curdoc()
if not isinstance(obj, (Plot, BokehServerWidgets)):
renderer = self_or_cls.instance(mode='server')
plot, _ = renderer._validate(obj, 'auto')
else:
plot = obj
root = plot.state
if isinstance(plot, BokehServerWidgets):
plot = plot.plot
plot.document = doc
plot.traverse(lambda x: attach_periodic(plot),
[GenericElementPlot])
plot.traverse(lambda x: attach_periodic(x), [GenericElementPlot])
doc.add_root(root)
return doc

Expand Down