Skip to content

Commit

Permalink
Made BokehRenderer.server_doc method more general
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 28, 2017
1 parent d23d3bc commit fff92d4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions holoviews/plotting/bokeh/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from ...core import Store, HoloMap
from ..comms import JupyterComm, Comm
from ..plot import GenericElementPlot
from ..plot import GenericElementPlot, Plot
from ..renderer import Renderer, MIME_TYPES
from .widgets import BokehScrubberWidget, BokehSelectionWidget, BokehServerWidgets
from .util import compute_static_patch, serialize_json, attach_periodic, bokeh_version
Expand Down Expand Up @@ -155,18 +155,23 @@ 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(plot, (Plot, BokehServerWidgets)):
renderer = self_or_cls.instance(mode='server')
plot, _ = renderer._validate(plot, 'auto')
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

0 comments on commit fff92d4

Please sign in to comment.