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

Improved API #1444

merged 3 commits into from May 16, 2017
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+35 −9
Diff settings


Just for now


Added options to

  • Loading branch information...
Philipp Rudiger Philipp Rudiger
Philipp Rudiger authored and Philipp Rudiger committed May 16, 2017
commit 460b18ef6a879056175fccc40aafe49aaef74a57
@@ -7,12 +7,13 @@
from bokeh.application import Application
from bokeh.charts import Chart
from bokeh.document import Document
from bokeh.embed import notebook_div
from import load_notebook, curdoc, show
from bokeh.embed import notebook_div, autoload_server
from import load_notebook, curdoc, show as bkshow
from bokeh.models import (Row, Column, Plot, Model, ToolbarBox,
WidgetBox, Div, DataTable, Tabs)
from bokeh.plotting import Figure
from bokeh.resources import CDN, INLINE
from bokeh.server.server import Server

from ...core import Store, HoloMap
from ..comms import JupyterComm, Comm
@@ -109,25 +110,49 @@ def get_widget(self_or_cls, plot, widget_type, doc=None, **kwargs):

def app(self_or_cls, plot, notebook=False):
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
returns the Document, if notebook option is supplied creates
an Application instance, displays it and returns it.
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.
Using the new_window option the app may be displayed in a
new browser tab once the notebook extension has been loaded.
renderer = self_or_cls.instance(mode='server')
if not notebook:
# If show=False and not in noteboook context return document
if not show and not self_or_cls.notebook_context:
doc, _ = renderer(plot)
return doc

def modify_doc(doc):
renderer(plot, doc=doc)

handler = FunctionHandler(modify_doc)
app = Application(handler)
return app

if not show:
# If not showing and in notebook context return app
return app
elif self_or_cls.notebook_context and not new_window:
# If in notebook, show=True and no new window requested
# display app inline
return bkshow(app)

# If app shown outside notebook or new_window requested
# start server and open in new browser tab
from tornado.ioloop import IOLoop
loop = IOLoop.current()
server = Server({'/': app}, port=0, loop=loop)
def show_callback():'/')
except RuntimeError:
return server

def server_doc(self, plot, doc=None):
@@ -170,6 +195,7 @@ def diff(self, plot, serialize=True):
processed = self._apply_post_render_hooks(patch, plot, 'json')
return serialize_json(processed) if serialize else processed

def plot_options(cls, obj, percent_size):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.