Various kinds of layout components.
Bases: FlexBox
Lay out child components in a single vertical row.
Children can be specified as positional arguments, as a single argument that is a sequence, or using the children
keyword argument.
{ "align": "auto", "aspect_ratio": null, "children": [], "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61332", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "spacing": 0, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
The list of children, which can be other components including plots, rows, columns, and widgets.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
The gap between children (in pixels).
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
Abstract base class for Row and Column. Do not use directly.
Note
This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.
{ "align": "auto", "aspect_ratio": null, "children": [], "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61362", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "spacing": 0, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
The list of children, which can be other components including plots, rows, columns, and widgets.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
The gap between children (in pixels).
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
, GridCommon
A CSS grid-based grid container.
{ "align": "auto", "aspect_ratio": null, "children": [], "cols": null, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61392", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "rows": null, "sizing_mode": null, "spacing": 0, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
A list of children with their associated position in the grid (row, column).
Describes how the grid should maintain its columnsâ widths.
This maps to CSS gridâs track sizing options. In particular the following values are allowed:
length, e.g. 100px
, 5.5em
percentage, e.g. 33%
flex, e.g. 1fr
enums, e.g. max-content
, min-content
, auto
, etc.
If a single value is provided, then it applies to all columns. A list of values can be provided to size all columns, or a dictionary providing sizing for individual columns.
See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns or https://w3c.github.io/csswg-drafts/css-grid/#track-sizing for details.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
Describes how the grid should maintain its rowsâ heights.
This maps to CSS gridâs track sizing options. In particular the following values are allowed:
length, e.g. 100px
, 5.5em
percentage, e.g. 33%
flex, e.g. 1fr
enums, e.g. max-content
, min-content
, auto
, etc.
If a single value is provided, then it applies to all rows. A list of values can be provided to size all rows, or a dictionary providing sizing for individual rows.
See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows or https://w3c.github.io/csswg-drafts/css-grid/#track-sizing for details.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
The gap between children (in pixels).
Either a number, if spacing is the same for both dimensions, or a pair of numbers indicating spacing in the vertical and horizontal dimensions respectively.
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
A panel that allows to group UI elements.
{ "align": "auto", "aspect_ratio": null, "checkable": false, "child": { "name": "unset", "type": "symbol" }, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61424", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "title": null, "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
Whether to allow disabling this group (all its children) via a checkbox in the UI. This allows to broadcast disabled
state across multiple UI controls that support that state.
The child UI element. This can be a single UI control, widget, etc., or a container layout like Column
or Row
, or a combitation of layouts.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
The title text of the group. If not provided, only the frame will be showed.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
A CSS grid-based horizontal box.
{ "align": "auto", "aspect_ratio": null, "children": [], "cols": null, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61455", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "spacing": 0, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
A list of children with their associated position in the horizontal box (optional; column number, span).
Describes how the grid should maintain its columnsâ widths.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
The gap between children (in pixels).
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: Pane
The base class for layoutable components.
Note
This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.
{ "align": "auto", "aspect_ratio": null, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61486", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: FlexBox
Lay out child components in a single horizontal row.
Children can be specified as positional arguments, as a single argument that is a sequence, or using the children
keyword argument.
{ "align": "auto", "aspect_ratio": null, "children": [], "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61514", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "spacing": 0, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
The list of children, which can be other components including plots, rows, columns, and widgets.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
The gap between children (in pixels).
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
A panel that allows to scroll overflowing UI elements.
{ "align": "auto", "aspect_ratio": null, "child": { "name": "unset", "type": "symbol" }, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "horizontal_scrollbar": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61544", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "vertical_scrollbar": "auto", "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
The child UI element. This can be a single UI control, widget, etc., or a container layout like Column
or Row
, or a combitation of layouts.
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
The visibility of the horizontal scrollbar.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
The visibility of the vertical scrollbar.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
A container for space used to fill an empty spot in a row or column.
{ "align": "auto", "aspect_ratio": null, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61575", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: Model
A single-widget container with title bar and controls.
{ "child": { "name": "unset", "type": "symbol" }, "closable": false, "disabled": false, "id": "p61603", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "name": null, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "title": "", "tooltip": null }
The child widget. If you need more children, use a layout widget, e.g. a Column
.
Whether this panel is closable or not. If True, an âxâ button will appear.
Closing a panel is equivalent to removing it from its parent container (e.g. tabs).
Whether the widget is responsive to UI events.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
The text title of the panel.
A tooltip with plain text or rich HTML contents, providing general help or description of a widgetâs or componentâs function.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
A panel widget with navigation tabs.
Example
from bokeh.models import TabPanel, Tabs, Tooltip from bokeh.models.layouts import Row from bokeh.plotting import figure, show p1 = figure(width=300, height=300) p1.scatter([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5) p2 = figure(width=300, height=300) p2.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=3, color="navy", alpha=0.5) p3 = figure(width=300, height=300) p3.scatter([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5) p4 = figure(width=300, height=300) p4.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=3, color="navy", alpha=0.5) tabs0 = Tabs(tabs=[ TabPanel(child=p1, title="circle"), TabPanel(child=p2, title="line"), ]) tabs1 = Tabs(tabs=[ TabPanel(child=p1, title="circle", tooltip=Tooltip(content="This is the first tab.", position="bottom_center")), TabPanel(child=p2, title="line", tooltip=Tooltip(content="This is the second tab.", position="bottom_center")), ]) show(Row(tabs0, tabs1))
{ "active": 0, "align": "auto", "aspect_ratio": null, "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61612", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "sizing_mode": null, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tabs": [], "tabs_location": "above", "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The index of the active tab.
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
The list of child panel widgets.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
Bases: LayoutDOM
A CSS grid-based vertical box.
{ "align": "auto", "aspect_ratio": null, "children": [], "context_menu": null, "css_classes": [], "css_variables": { "type": "map" }, "disabled": false, "elements": [], "flow_mode": "block", "height": null, "height_policy": "auto", "html_attributes": { "type": "map" }, "html_id": null, "id": "p61824", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "resizable": false, "rows": null, "sizing_mode": null, "spacing": 0, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "width": null, "width_policy": "auto" }
The alignment point within the parent container.
This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).
Describes the proportional relationship between componentâs width and height.
This works if any of componentâs dimensions are flexible in size. If set to a number, width / height = aspect_ratio
relationship will be maintained. Otherwise, if set to "auto"
, componentâs preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).
A list of children with their associated position in the vertical box (optional; row number, span).
A menu to display when user right clicks on the component.
If set to "auto"
, the component may provide a dynamically generated menu. For example, Plot
and related models provide a ToolMenu
instance for easy access to their tools.
Note
Use shift key when right clicking to display the native context menu.
A list of additional CSS classes to add to the underlying DOM element.
Allows to define dynamically computed CSS variables.
This can be used, for example, to coordinate positioning and styling between canvasâ renderers and/or visuals and HTML-based UI elements.
Variables defined here are equivalent to setting the same variables under :host { ... }
in a CSS stylesheet.
Note
This property is experimental and may change at any point.
Whether the widget will be disabled when rendered.
If True
, the widget will be greyed-out and not responsive to UI events.
A collection of DOM-based UI elements attached to this pane.
This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.
Defines whether the layout will flow in the block
or inline
dimension.
The height of the component (in pixels).
This can be either fixed or preferred height, depending on height sizing policy.
Describes how the component should maintain its height.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly height
pixels. Component will overflow if it canât fit in the available vertical space.
"fit"
Use componentâs preferred height (if set) and allow to fit into the available vertical space within the minimum and maximum height bounds (if set). Componentâs height neither will be aggressively minimized nor maximized.
"min"
Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Allows to configure HTML attributes on the underlying HTML element.
Sets the id
attribute of the underlying HTML element.
This is a shorthand for the common HTML id
attribute. Alternatively the id
can be set in the html_attributes
dictionary. html_id
takes precedence.
Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.
Maximal height of the component (in pixels) if height is adjustable.
Maximal width of the component (in pixels) if width is adjustable.
Minimal height of the component (in pixels) if height is adjustable.
Minimal width of the component (in pixels) if width is adjustable.
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.scatter([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
Note
No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.
Either
(Bool
, Enum
(Dimensions
))
Whether the layout is interactively resizable, and if so in which dimensions.
Describes how the grid should maintain its rowsâ heights.
How the component should size itself.
This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy
, height_policy
and aspect_ratio
instead (those take precedence over sizing_mode
).
Possible scenarios:
"inherit"
The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode
was provided.
"fixed"
Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.
"stretch_width"
Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_height"
Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to componentâs contents.
"stretch_both"
Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.
"scale_width"
Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.
"scale_height"
Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.
"scale_both"
Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.
The gap between children (in pixels).
Inline CSS styles applied to the underlying DOM element.
Additional style-sheets to use for the underlying DOM element.
Note that all bokehâs components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host
CSS pseudo selector to access the root DOM element.
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False
may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we donât need.
Note
Setting this property to False
will prevent any on_change()
callbacks on this object from triggering. However, any JS-side callbacks will still work.
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.scatter([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS
callbacks, etc.
Note
No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.
Whether the component should be displayed on screen.
The width of the component (in pixels).
This can be either fixed or preferred width, depending on width sizing policy.
Describes how the component should maintain its width.
"auto"
Use componentâs preferred sizing policy.
"fixed"
Use exactly width
pixels. Component will overflow if it canât fit in the available horizontal space.
"fit"
Use componentâs preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Componentâs width neither will be aggressively minimized nor maximized.
"min"
Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
"max"
Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.
Note
This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode
if this level of control isnât strictly necessary.
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps
instance should modify it).
property_values (dict) â theme values to use in place of defaults
None
Clear any currently defined custom extensions.
Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utilized. This method can be used to clear out all existing custom extension definitions.
Duplicate a HasProps
object.
This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.
Collect the names of all DataSpec
properties on this class.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
List of property descriptors in the order of definition.
Clean up references to the document and property
Structural equality of models.
other (HasProps) â the other instance to compare to
True, if properties are structurally equal, otherwise False
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS
callback to update one Bokeh model property whenever another changes value.
Added in version 1.1
ValueError â
Examples
This code with js_link
:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plotâs x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
Attach a CustomJS
callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name"
. As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:"
automatically:
# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource
, use the "stream"
event on the source:
source.js_on_change('streaming', callback)
Find the PropertyDescriptor
for a Bokeh property on a class, given the property name.
descriptor for property named name
Add a callback on this object to trigger when attr
changes.
attr (str) â an attribute name on this object
*callbacks (callable) â callback functions to register
None
Examples
widget.on_change('value', callback1, callback2, ..., callback_n)
Run callbacks when the specified event occurs on this Model
Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.
Generate Python Parameter
values suitable for functions that are derived from the glyph.
list(Parameter)
Collect the names of properties on this class.
Warning
In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list
.
property names
Collect the names of all properties on this class that also have references.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Collect a dict mapping property names to their values.
This method always traverses the class hierarchy and includes properties defined on any parent classes.
Non-serializable properties are skipped and property values are in âserializedâ format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.
Query the properties values of HasProps
instances with a predicate.
query (callable) â A callable that accepts property descriptors and returns True or False
include_defaults (bool, optional) â Whether to include properties that have not been explicitly set by a user (default: True)
mapping of property names and values for matching properties
Returns all Models
that this object has references to.
Remove a callback from this object
Query this object and all of its references for objects that match the given selector.
selector (JSON-like)
seq[Model]
Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like
Model
Set a property value on this object from JSON.
name (str) â name of the attribute to set
value (JSON-value) â value to set to the attribute to
setter (ClientSession or ServerSession or None, optional) â
This is used to prevent âboomerangâ updates to Bokeh apps.
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.
None
Update objects that match a given selector with the specified attribute/value updates.
selector (JSON-like)
updates (dict)
None
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None
if no theme overrides any values for this instance.
dict or None
Converts this object to a serializable representation.
Remove any themed values and restore defaults.
None
Updates the objectâs properties from the given keyword arguments.
None
Examples
The following are equivalent:
from bokeh.models import Range1d r = Range1d # set properties individually: r.start = 10 r.end = 20 # update properties together: r.update(start=10, end=20)
The Document
this model is attached to (can be None
)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4