本文整理汇总了Python中bokeh.io.curdoc方法的典型用法代码示例。如果您正苦于以下问题:Python io.curdoc方法的具体用法?Python io.curdoc怎么用?Python io.curdoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.io
的用法示例。
在下文中一共展示了io.curdoc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _bokeh_cb_push_adds
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def _bokeh_cb_push_adds(self, bootstrap_document=None):
if bootstrap_document is None:
document = curdoc()
else:
document = bootstrap_document
with self._lock:
client = self._clients[document.session_context.id]
updatepkg_df: pandas.DataFrame = self._datastore[self._datastore['index'] > client.last_data_index]
# skip if we don't have new data
if updatepkg_df.shape[0] == 0:
return
updatepkg = ColumnDataSource.from_df(updatepkg_df)
client.push_adds(updatepkg, new_last_index=updatepkg_df['index'].iloc[-1])
示例2: show_exception_page
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def show_exception_page():
""" show an error page in case of an unknown/unhandled exception """
title = 'Internal Error'
error_message = ('<h3>Internal Server Error</h3>'
'<p>Please open an issue on <a '
'href="https://github.com/PX4/flight_review/issues" target="_blank">'
'https://github.com/PX4/flight_review/issues</a> with a link '
'to this log.')
div = Div(text=error_message, width=int(plot_width*0.9))
plots = [widgetbox(div, width=int(plot_width*0.9))]
curdoc().template_variables['internal_error'] = True
return (title, error_message, plots)
# check which plots to show
示例3: app
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def app(self_or_cls, plot, show=False, new_window=False, websocket_origin=None, port=0):
"""
Creates a bokeh app from a HoloViews object or plot. By
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. Using
the new_window option the app may be displayed in a new
browser tab once the notebook extension has been loaded. A
websocket origin is required when launching from an existing
tornado server (such as the notebook) and it is not on the
default port ('localhost:8888').
"""
if isinstance(plot, HoloViewsPane):
pane = plot
else:
pane = HoloViewsPane(plot, backend=self_or_cls.backend, renderer=self_or_cls,
**self_or_cls._widget_kwargs())
if new_window:
return pane._get_server(port, websocket_origin, show=show)
else:
kwargs = {'notebook_url': websocket_origin} if websocket_origin else {}
return pane.app(port=port, **kwargs)
示例4: get_root
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def get_root(self, doc=None, comm=None):
"""
Returns the root model and applies pre-processing hooks
Arguments
---------
doc: bokeh.Document
Bokeh document the bokeh model will be attached to.
comm: pyviz_comms.Comm
Optional pyviz_comms when working in notebook
Returns
-------
Returns the bokeh model corresponding to this panel object
"""
doc = doc or _curdoc()
root = self.layout.get_root(doc, comm)
ref = root.ref['id']
self._models[ref] = (root, None)
state._views[ref] = (self, root, doc, comm)
return root
示例5: get_root
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def get_root(self, doc=None, comm=None):
"""
Returns the root model and applies pre-processing hooks
Arguments
---------
doc: bokeh.Document
Bokeh document the bokeh model will be attached to.
comm: pyviz_comms.Comm
Optional pyviz_comms when working in notebook
Returns
-------
Returns the bokeh model corresponding to this panel object
"""
doc = doc or _curdoc()
if self._updates:
root = self._get_model(doc, comm=comm)
else:
root = self.layout._get_model(doc, comm=comm)
self._preprocess(root)
ref = root.ref['id']
state._views[ref] = (self, root, doc, comm)
return root
示例6: theme
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def theme(name):
"""Set color theme.
:param name: name of theme
>>> import arlpy.plot
>>> arlpy.plot.theme('dark')
"""
if name == 'dark':
name = 'dark_minimal'
set_colors(dark_palette)
elif name == 'light':
name = 'light_minimal'
set_colors(light_palette)
_bio.curdoc().theme = name
示例7: _on_select_group
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def _on_select_group(self, a, old, new):
_logger.info(f"Switching logic group to {new}...")
self._current_group = new
doc = curdoc()
doc.hold()
self._refreshmodel()
doc.unhold()
self._push_data_fnc(doc)
_logger.info(f"Switching logic group finished")
示例8: _bokeh_cb_push_patches
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def _bokeh_cb_push_patches(self):
document = curdoc()
session_id = document.session_context.id
with self._lock:
client: LiveClient = self._clients[session_id]
patch_pkgs = self._patch_pkgs[session_id]
self._patch_pkgs[session_id] = []
client.push_patches(patch_pkgs)
示例9: animate
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def animate():
if button.label == ' Play':
button.label = ' Pause'
curdoc().add_periodic_callback(animate_update, 10)
else:
button.label = ' Play'
curdoc().remove_periodic_callback(animate_update)
示例10: plan_update_data
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def plan_update_data(self):
doc = curdoc()
if self._update_complete == True:
self._update_complete = False
self._ntcb = doc.add_next_tick_callback(self.update_data)
示例11: stop_update_data
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def stop_update_data(self):
doc = curdoc()
try:
doc.remove_periodic_callback(self._pcb)
except:
pass
if self._recurring_update.is_running:
self._recurring_update.stop()
while self._recurring_update.is_running:
pass
try:
doc.remove_next_tick_callback(self._ntcb)
except (ValueError, RuntimeError):
pass # Already gone
示例12: update_data
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def update_data(self):
controller = self.network.notes[0]
notes_df = pd.DataFrame(self.network.notes[1]).reset_index()
notes_df.columns = ["index", "notes"]
notes = ColumnDataSource(notes_df)
self.data_table.source.data.update(notes.data)
curdoc().title = "Notes for {}".format(controller)
示例13: server_doc
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def server_doc(self_or_cls, obj, doc=None):
"""
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 not isinstance(obj, HoloViewsPane):
obj = HoloViewsPane(obj, renderer=self_or_cls, backend=self_or_cls.backend,
**self_or_cls._widget_kwargs())
return obj.layout.server_doc(doc)
示例14: get_plot
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def get_plot(self_or_cls, obj, doc=None, renderer=None, **kwargs):
"""
Given a HoloViews Viewable return a corresponding plot instance.
Allows supplying a document attach the plot to, useful when
combining the bokeh model with another plot.
"""
plot = super(BokehRenderer, self_or_cls).get_plot(obj, doc, renderer, **kwargs)
if plot.document is None:
plot.document = Document() if self_or_cls.notebook_context else curdoc()
plot.document.theme = self_or_cls.theme
return plot
示例15: tearDown
# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import curdoc [as 别名]
def tearDown(self):
Store.current_backend = self.previous_backend
bokeh_renderer.last_plot = None
Callback._callbacks = {}
with param.logging_level('ERROR'):
Renderer.notebook_context = self.nbcontext
state.curdoc = None
curdoc().clear()
time.sleep(1)