bokeh.document.events¶
Provide events that represent various changes to Bokeh Documents.
These events are used internally to signal changes to Documents. For information about user-facing (e.g. UI or tool) events, see the reference for bokeh.events.
-
class
ColumnDataChangedEvent
(document, column_source, cols=None, setter=None)[source]¶ A concrete event representing efficiently replacing all existing data for a
ColumnDataSource
-
__init__
(document, column_source, cols=None, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- column_source (ColumnDataSource) –
- cols (list[str]) – optional explicit list of column names to update. If None, all columns will be updated (default: None)
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
dispatch
(receiver)[source]¶ Dispatch handling of this event to a receiver.
This method will invoke
receiver._column_data_changed
if it exists.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
{ 'kind' : 'ColumnDataChanged' 'column_source' : <reference to a CDS> 'new' : <new data to steam to column_source> 'cols' : <specific columns to update> }
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
ColumnsPatchedEvent
(document, column_source, patches, setter=None)[source]¶ A concrete event representing efficiently applying data patches to a
ColumnDataSource
-
__init__
(document, column_source, patches, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- column_source (ColumnDataSource) – The data source to apply patches to.
- patches (list) –
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
dispatch
(receiver)[source]¶ Dispatch handling of this event to a receiver.
This method will invoke
receiver._columns_patched
if it exists.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
{ 'kind' : 'ColumnsPatched' 'column_source' : <reference to a CDS> 'patches' : <patches to apply to column_source> }
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
ColumnsStreamedEvent
(document, column_source, data, rollover, setter=None)[source]¶ A concrete event representing efficiently streaming new data to a
ColumnDataSource
-
__init__
(document, column_source, data, rollover, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- column_source (ColumnDataSource) – The data source to stream new data to.
- data (dict) –
- rollover (int) – A rollover limit. If the data source columns exceed this limit, earlier values will be discarded to maintain the column length under the limit.
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
dispatch
(receiver)[source]¶ Dispatch handling of this event to a receiver.
This method will invoke
receiver._columns_streamed
if it exists.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
{ 'kind' : 'ColumnsStreamed' 'column_source' : <reference to a CDS> 'data' : <new data to steam to column_source> 'rollover' : <rollover limit> }
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
DocumentChangedEvent
(document, setter=None)[source]¶ Base class for all internal events representing a change to a Bokeh Document.
-
__init__
(document, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.
-
-
class
DocumentPatchedEvent
(document, setter=None)[source]¶ A Base class for events that represent updating Bokeh Models and their properties.
-
dispatch
(receiver)[source]¶ Dispatch handling of this event to a receiver.
This method will invoke
receiver._document_patched
if it exists.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
Sub-classes must implement this method.
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
ModelChangedEvent
(document, model, attr, old, new, serializable_new, hint=None, setter=None)[source]¶ A concrete event representing updating an attribute and value of a specific Bokeh Model.
This is the “standard” way of updating most Bokeh model attributes. For special casing situations that can optimized (e.g. streaming, etc.), a
hint
may be supplied that overrides normal mechanisms.-
__init__
(document, model, attr, old, new, serializable_new, hint=None, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- model (Model) – A Model to update
- attr (str) – The name of the attribute to update on the model.
- old (object) – The old value of the attribute
- new (object) – The new value of the attribute
- serializable_new (object) – A serialized (JSON) version of the new value. It may be
None
if a hint is supplied. - hint (DocumentPatchedEvent, optional) – When appropriate, a secondary event may be supplied that modifies the normal update process. For example, in order to stream or patch data more efficiently than the standard update mechanism.
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
dispatch
(receiver)[source]¶ Dispatch handling of this event to a receiver.
This method will invoke
receiver._document_model_dhanged
if it exists.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
RootAddedEvent
(document, model, setter=None)[source]¶ A concrete event representing a change to add a new Model to a Document’s collection of “root” models.
-
__init__
(document, model, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- model (Model) – The Bokeh Model to add as a Document root.
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
{ 'kind' : 'RootAdded' 'title' : <reference to a Model> }
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
RootRemovedEvent
(document, model, setter=None)[source]¶ A concrete event representing a change to remove an existing Model from a Document’s collection of “root” models.
-
__init__
(document, model, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- model (Model) – The Bokeh Model to remove as a Document root.
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
{ 'kind' : 'RootRemoved' 'title' : <reference to a Model> }
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-
-
class
SessionCallbackAdded
(document, callback)[source]¶ A concrete event representing a change to add a new callback (e.g. periodic, timeout, or “next tick”) to a Document.
-
__init__
(document, callback)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- callback (SessionCallback) – The callback to add
-
-
class
SessionCallbackRemoved
(document, callback)[source]¶ A concrete event representing a change to remove an existing callback (e.g. periodic, timeout, or “next tick”) from a Document.
-
__init__
(document, callback)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- callback (SessionCallback) – The callback to remove
-
-
class
TitleChangedEvent
(document, title, setter=None)[source]¶ A concrete event representing a change to the title of a Bokeh Document.
-
__init__
(document, title, setter=None)[source]¶ Parameters: - document (Document) – A Bokeh document that is to be updated.
- title (str) – The new title to set on the Document
- setter (ClientSession or ServerSession or None, optional) –
This is used to prevent “boomerang” updates to Bokeh apps. (default: None)
See
DocumentChangedEvent
for more details.
-
generate
(references, buffers)[source]¶ Create a JSON representation of this event suitable for sending to clients.
{ 'kind' : 'TitleChanged' 'title' : <new title to set> }
Parameters: - references (dict[str, Model]) –
If the event requires references to certain models in order to function, they may be collected here.
This is an “out” parameter. The values it contains will be modified in-place.
- buffers (set) –
If the event needs to supply any additional Bokeh protocol buffers, they may be added to this set.
This is an “out” parameter. The values it contains will be modified in-place.
- references (dict[str, Model]) –
-