Bokeh comes with a number of interactive tools.
There are five types of tool interactions:
Pan/Drag
Click/Tap
Scroll/Pinch
Actions
Inspectors
For the first three comprise the category of gesture tools, and only one tool for each gesture can be active at any given time. The active tool is indicated on the toolbar by a highlight next to the tool. Actions are immediate or modal operations that are only activated when their button in the toolbar is pressed. Inspectors are passive tools that merely report information or annotate the plot in some way, and may always be active regardless of what other tools are currently active.
Action
alias of bokeh.models.tools.ActionTool
bokeh.models.tools.ActionTool
ActionTool
Bases: bokeh.models.tools.Tool
bokeh.models.tools.Tool
A base class for tools that are buttons in the toolbar.
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.
description
Nullable(String)
Nullable
String
None
A string describing the purpose of this tool. If not defined, an auto-generated description will be used. This description will be typically presented in the user interface as a tooltip.
js_event_callbacks
Dict(String, List(Instance(CustomJS)))
Dict
List
Instance
CustomJS
{}
A mapping of event names to lists of CustomJS callbacks.
Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:
Model.js_on_event
callback = CustomJS(code="console.log('tap event occurred')") plot.js_on_event('tap', callback)
js_property_callbacks
A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.
Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:
Model.js_on_change
callback = CustomJS(code="console.log('stuff')") plot.x_range.js_on_change('start', callback)
name
An arbitrary, user-supplied name for this model.
This name can be useful when querying the document to retrieve specific Bokeh models.
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
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.
subscribed_events
List(String)
[]
List of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.
syncable
Bool
True
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.
False
Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.
on_change()
tags
List(AnyRef)
AnyRef
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.circle([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.
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.
apply_theme
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).
HasProps
property_values (dict) – theme values to use in place of defaults
dataspecs
Collect the names of all DataSpec properties on this class.
DataSpec
This method always traverses the class hierarchy and includes properties defined on any parent classes.
names of DataSpec properties
set[str]
dataspecs_with_props
Collect a dict mapping the names of all DataSpec properties on this class to the associated properties.
mapping of names and DataSpec properties
dict[str, DataSpec]
equals
Structural equality of models.
other (HasProps) – the other instance to compare to
True, if properties are structurally equal, otherwise False
from_string
Takes a string and returns a corresponding Tool instance.
js_link
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.
attr (str) – The name of a Bokeh property on this model
other (Model) – A Bokeh model to link to self.attr
other_attr (str) – The property on other to link together
other
attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr
attr
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]" ) )
js_on_change
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:
"change:property_name"
"change:"
# 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:
ColumnDataSource
"stream"
source.js_on_change('streaming', callback)
layout
lookup
Find the PropertyDescriptor for a Bokeh property on a class, given the property name.
PropertyDescriptor
name (str) – name of the property to search for
raises (bool) – whether to raise or return None if missing
descriptor for property named name
on_change
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
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
on_event
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.
properties
Collect the names of properties on this class.
This method optionally traverses the class hierarchy and includes properties defined on any parent classes.
with_bases (bool, optional) – Whether to include properties defined on parent classes in the results. (default: True)
property names
properties_containers
Collect the names of all container properties on this class.
names of container properties
properties_with_refs
Collect the names of all properties on this class that also have references.
names of properties that have references
properties_with_values
Collect a dict mapping property names to their values.
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.
include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)
mapping from property names to their values
dict
query_properties_with_values
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
references
Returns all Models that this object has references to.
Models
remove_on_change
Remove a callback from this object
select
Query this object and all of its references for objects that match the given selector.
selector (JSON-like) –
seq[Model]
select_one
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_from_json
Set a property value on this object from JSON.
name – (str) : name of the attribute to set
json – (JSON-value) : value to set to the attribute to
models (dict or None, optional) –
Mapping of model ids to models (default: None)
This is needed in cases where the attributes to update also have values that have references.
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.
set_select
Update objects that match a given selector with the specified attribute/value updates.
updates (dict) –
themed_values
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
to_json
Returns a dictionary of the attributes of this object, containing only “JSON types” (string, number, boolean, none, dict, list).
References to other objects are serialized as “refs” (just the object ID and type info), so the deserializer will need to separately have the full attributes of those other objects.
There’s no corresponding from_json() because to deserialize an object is normally done in the context of a Document (since the Document can resolve references).
from_json()
For most purposes it’s best to serialize and deserialize entire documents.
include_defaults (bool) – whether to include attributes that haven’t been changed from the default
to_json_string
Returns a JSON string encoding the attributes of this object.
References to other objects are serialized as references (just the object ID and type info), so the deserializer will need to separately have the full attributes of those other objects.
There’s no corresponding from_json_string() because to deserialize an object is normally done in the context of a Document (since the Document can resolve references).
from_json_string()
trigger
unapply_theme
Remove any themed values and restore defaults.
update
Updates the object’s properties from the given keyword arguments.
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)
update_from_json
Updates the object’s properties from a JSON attributes dictionary.
json_attributes – (JSON-dict) : attributes and values to update
document
The Document this model is attached to (can be None)
Document
struct
A Bokeh protocol “structure” of this model, i.e. a dict of the form:
{ 'type' : << view model name >> 'id' : << unique model id >> }
Additionally there may be a subtype field if this model is a subtype.
{ "description": null, "id": "19078", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "subscribed_events": [], "syncable": true, "tags": [] }
BoxEditTool
Bases: bokeh.models.tools.EditTool, bokeh.models.tools.Drag, bokeh.models.tools.Tap
bokeh.models.tools.EditTool
bokeh.models.tools.Drag
bokeh.models.tools.Tap
toolbar icon:
Allows drawing, dragging and deleting Rect glyphs on one or more renderers by editing the underlying ColumnDataSource data. Like other drawing tools, the renderers that are to be edited must be supplied explicitly as a list. When drawing a new box the data will always be added to the ColumnDataSource on the first supplied renderer.
Rect
The tool will modify the columns on the data source corresponding to the x, y, width and height values of the glyph. Any additional columns in the data source will be padded with empty_value, when adding a new box.
x
y
width
height
empty_value
The supported actions include:
Add box: Hold shift then click and drag anywhere on the plot or double tap once to start drawing, move the mouse and double tap again to finish drawing.
Move box: Click and drag an existing box, the box will be dropped once you let go of the mouse button.
Delete box: Tap a box to select it then press <<backspace>> key while the mouse is within the plot area.
To Move or Delete multiple boxes at once:
Move selection: Select box(es) with <<shift>>+tap (or another selection tool) then drag anywhere on the plot. Selecting and then dragging on a specific box will move both.
Delete selection: Select box(es) with <<shift>>+tap (or another selection tool) then press <<backspace>> while the mouse is within the plot area.
custom_icon
Nullable(Image)
Image
An icon to display in the toolbar.
The icon can provided as a string filename for an image, a PIL Image object, or an RGB(A) NumPy array.
dimensions
Enum(Dimensions)
Enum
Dimensions
'both'
Which dimensions the box drawing is to be free in. By default, users may freely draw boxes with any dimensions. If only “width” is set, the box will be constrained to span the entire vertical space of the plot, only the horizontal dimension can be controlled. If only “height” is set, the box will be constrained to span the entire horizontal space of the plot, and the vertical dimension can be controlled.
NonNullable(Either(Bool, Int, Float, Date, Datetime, Color, String))
NonNullable
Either
Int
Float
Date
Datetime
Color
Undefined
Defines the value to insert on non-coordinate columns when a new glyph is inserted into the ColumnDataSource columns, e.g. when a circle glyph defines ‘x’, ‘y’ and ‘color’ columns, adding a new point will add the x and y-coordinates to ‘x’ and ‘y’ columns and the color column will be filled with the defined empty value.
num_objects
0
Defines a limit on the number of boxes that can be drawn. By default there is no limit on the number of objects, but if enabled the oldest drawn box will be dropped to make space for the new box being added.
renderers
List(Instance(GlyphRenderer))
GlyphRenderer
An explicit list of renderers corresponding to scatter glyphs that may be edited.
{ "custom_icon": null, "description": null, "dimensions": "both", "id": "19086", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "num_objects": 0, "renderers": [], "subscribed_events": [], "syncable": true, "tags": [] }
BoxSelectTool
Bases: bokeh.models.tools.Drag, bokeh.models.tools.SelectTool
bokeh.models.tools.SelectTool
The box selection tool allows users to make selections on a Plot by showing a rectangular region by dragging the mouse or a finger over the plot area. The end of the drag event indicates the selection region is ready.
See Selected and unselected glyphs for information on styling selected and unselected glyphs.
Which dimensions the box selection is to be free in. By default, users may freely draw selections boxes with any dimensions. If only “width” is set, the box will be constrained to span the entire vertical space of the plot, only the horizontal dimension can be controlled. If only “height” is set, the box will be constrained to span the entire horizontal space of the plot, and the vertical dimension can be controlled.
mode
Enum(SelectionMode)
SelectionMode
'replace'
Defines what should happen when a new selection is made. The default is to replace the existing selection. Other options are to append to the selection, intersect with it or subtract from it.
names
A list of names to query for. If set, only renderers that have a matching value for their name attribute will be used.
origin
Enum(Enumeration(corner, center))
'corner'
Indicates whether the rectangular selection area should originate from a corner (top-left or bottom-right depending on direction) or the center of the box.
overlay
Instance(BoxAnnotation)
BoxAnnotation
BoxAnnotation(id='19110', ...)
A shaded annotation drawn to indicate the selection region.
Either(Auto, List(Instance(DataRenderer)))
Auto
DataRenderer
'auto'
An explicit list of renderers to hit test against. If unset, defaults to all renderers on a plot.
select_every_mousemove
Whether a selection computation should happen on every mouse event, or only once, when the selection region is completed. Default: False
{ "description": null, "dimensions": "both", "id": "19099", "js_event_callbacks": {}, "js_property_callbacks": {}, "mode": "replace", "name": null, "names": [], "origin": "corner", "overlay": { "id": "19100" }, "renderers": "auto", "select_every_mousemove": false, "subscribed_events": [], "syncable": true, "tags": [] }
BoxZoomTool
Bases: bokeh.models.tools.Drag
The box zoom tool allows users to define a rectangular egion of a Plot to zoom to by dragging he mouse or a finger over the plot region. The end of the drag event indicates the selection region is ready.
BoxZoomTool is incompatible with GMapPlot due to the manner in which Google Maps exert explicit control over aspect ratios. Adding this tool to a GMapPlot will have no effect.
GMapPlot
Which dimensions the zoom box is to be free in. By default, users may freely draw zoom boxes with any dimensions. If only “width” is supplied, the box will be constrained to span the entire vertical space of the plot, only the horizontal dimension can be controlled. If only “height” is supplied, the box will be constrained to span the entire horizontal space of the plot, and the vertical dimension can be controlled.
match_aspect
Whether the box zoom region should be restricted to have the same aspect ratio as the plot region.
If the tool is restricted to one dimension, this value has no effect.
Indicates whether the rectangular zoom area should originate from a corner (top-left or bottom-right depending on direction) or the center of the box.
BoxAnnotation(id='19126', ...)
{ "description": null, "dimensions": "both", "id": "19116", "js_event_callbacks": {}, "js_property_callbacks": {}, "match_aspect": false, "name": null, "origin": "corner", "overlay": { "id": "19117" }, "subscribed_events": [], "syncable": true, "tags": [] }
CrosshairTool
Bases: bokeh.models.tools.InspectTool
bokeh.models.tools.InspectTool
The crosshair tool is a passive inspector tool. It is generally on at all times, but can be configured in the inspector’s menu associated with the toolbar icon shown above.
The crosshair tool draws a crosshair annotation over the plot, centered on the current mouse position. The crosshair tool may be configured to draw across only one dimension by setting the dimension property to only width or height.
dimension
Which dimensions the crosshair tool is to track. By default, both vertical and horizontal lines will be drawn. If only “width” is supplied, only a horizontal line will be drawn. If only “height” is supplied, only a vertical line will be drawn.
line_alpha
Alpha
1.0
An alpha value to use to stroke paths with.
Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).
line_color
'black'
A color to use to stroke paths with.
Acceptable values are:
any of the named CSS colors, e.g 'green', 'indigo'
'green'
'indigo'
RGB(A) hex strings, e.g., '#FF0000', '#44444444'
'#FF0000'
'#44444444'
CSS4 color strings, e.g., 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 / 1.0)', or 'hsl(60deg 100% 50% / 1.0)'
'rgba(255, 0, 127, 0.6)'
'rgb(0 127 0 / 1.0)'
'hsl(60deg 100% 50% / 1.0)'
a 3-tuple of integers (r, g, b) between 0 and 255
a 4-tuple of (r, g, b, a) where r, g, b are integers between 0 and 255, and a is between 0 and 1
a 32-bit unsigned integer using the 0xRRGGBBAA byte order pattern
line_width
1
Stroke width in units of pixels.
toggleable
Whether an on/off toggle button should appear in the toolbar for this inspection tool. If False, the viewers of a plot will not be able to toggle the inspector on or off using the toolbar.
{ "description": null, "dimensions": "both", "id": "19130", "js_event_callbacks": {}, "js_property_callbacks": {}, "line_alpha": 1.0, "line_color": "black", "line_width": 1, "name": null, "subscribed_events": [], "syncable": true, "tags": [], "toggleable": true }
CustomAction
Bases: bokeh.models.tools.ActionTool
Execute a custom action, e.g. CustomJS callback when a toolbar icon is activated.
Example
tool = CustomAction(icon="icon.png", callback=CustomJS(code='alert("foo")')) plot.add_tools(tool)
callback
Nullable(Instance(Callback))
Callback
A Bokeh callback to execute when the custom action icon is activated.
'Perform a Custom Action'
icon
{ "callback": null, "description": "Perform a Custom Action", "id": "19143", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "subscribed_events": [], "syncable": true, "tags": [] }
CustomJSHover
Bases: bokeh.model.Model
bokeh.model.Model
Define a custom formatter to apply to a hover tool field.
This model can be configured with JavaScript code to format hover tooltips. The JavaScript code has access to the current value to format, some special variables, and any format configured on the tooltip. The variable value will contain the untransformed value. The variable special_vars will provide a dict with the following contents:
value
special_vars
x data-space x-coordinate of the mouse
y data-space y-coordinate of the mouse
sx screen-space x-coordinate of the mouse
sx
sy screen-space y-coordinate of the mouse
sy
data_x data-space x-coordinate of the hovered glyph
data_x
data_y data-space y-coordinate of the hovered glyph
data_y
indices column indices of all currently hovered glyphs
indices
name value of the name property of the hovered glyph renderer
If the hover is over a “multi” glyph such as Patches or MultiLine then a segment_index key will also be present.
Patches
MultiLine
segment_index
Finally, the value of the format passed in the tooltip specification is available as the format variable.
format
As an example, the following code adds a custom formatter to format WebMercator northing coordinates (in meters) as a latitude:
lat_custom = CustomJSHover(code=""" var projections = Bokeh.require("core/util/projections"); var x = special_vars.x var y = special_vars.y var coords = projections.wgs84_mercator.invert(x, y) return "" + coords[1] """) p.add_tools(HoverTool( tooltips=[( 'lat','@y{custom}' )], formatters={'@y':lat_custom} ))
Warning
The explicit purpose of this Bokeh Model is to embed raw JavaScript code for a browser to execute. If any part of the code is derived from untrusted user inputs, then you must take appropriate care to sanitize the user input prior to passing to Bokeh.
args
Dict(String, Instance(Model))
A mapping of names to Bokeh plot objects. These objects are made available to the callback code snippet as the values of named parameters to the callback.
code
''
A snippet of JavaScript code to transform a single value. The variable value will contain the untransformed value and can be expected to be present in the function namespace at render time. Additionally, the variable special_vars will be available, and will provide a dict with the following contents:
The snippet will be made into the body of a function and therefore requires a return statement.
code = ''' return value + " total" '''
{ "args": {}, "code": "", "id": "19153", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "subscribed_events": [], "syncable": true, "tags": [] }
Drag
Bases: bokeh.models.tools.GestureTool
bokeh.models.tools.GestureTool
A base class for tools that respond to drag events.
{ "description": null, "id": "19162", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "subscribed_events": [], "syncable": true, "tags": [] }
EditTool
A base class for all interactive draw tool types.
{ "custom_icon": null, "description": null, "id": "19170", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "renderers": [], "subscribed_events": [], "syncable": true, "tags": [] }
FreehandDrawTool
Allows freehand drawing of Patches and MultiLine glyphs. The glyph to draw may be defined via the renderers property.
The tool will modify the columns on the data source corresponding to the xs and ys values of the glyph. Any additional columns in the data source will be padded with the declared empty_value, when adding a new point.
xs
ys
Draw vertices: Click and drag to draw a line
Delete patch/multi-line: Tap a patch/multi-line to select it then press <<backspace>> key while the mouse is within the plot area.
Defines a limit on the number of patches or multi-lines that can be drawn. By default there is no limit on the number of objects, but if enabled the oldest drawn patch or multi-line will be overwritten when the limit is reached.
{ "custom_icon": null, "description": null, "id": "19181", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "num_objects": 0, "renderers": [], "subscribed_events": [], "syncable": true, "tags": [] }
Gesture
alias of bokeh.models.tools.GestureTool
GestureTool
{ "description": null, "id": "19193", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "subscribed_events": [], "syncable": true, "tags": [] }
HelpTool
A button tool to provide a “help” link to users.
The hover text can be customized through the help_tooltip attribute and the redirect site overridden as well.
help_tooltip
'Click the question mark to learn more about Bokeh plot tools.'
redirect
'https://docs.bokeh.org/en/latest/docs/user_guide/tools.html'
Site to be redirected through upon click.
{ "description": "Click the question mark to learn more about Bokeh plot tools.", "id": "19201", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "redirect": "https://docs.bokeh.org/en/latest/docs/user_guide/tools.html", "subscribed_events": [], "syncable": true, "tags": [] }
HoverTool
The hover tool is a passive inspector tool. It is generally on at all times, but can be configured in the inspector’s menu associated with the toolbar icon shown above.
By default, the hover tool displays informational tooltips whenever the cursor is directly over a glyph. The data to show comes from the glyph’s data source, and what to display is configurable with the tooltips property that maps display names to columns in the data source, or to special known variables.
tooltips
Here is an example of how to configure and use the hover tool:
# Add tooltip (name, field) pairs to the tool. See below for a # description of possible field values. hover.tooltips = [ ("index", "$index"), ("(x,y)", "($x, $y)"), ("radius", "@radius"), ("fill color", "$color[hex, swatch]:fill_color"), ("fill color", "$color[hex]:fill_color"), ("fill color", "$color:fill_color"), ("fill color", "$swatch:fill_color"), ("foo", "@foo"), ("bar", "@bar"), ("baz", "@baz{safe}"), ("total", "@total{$0,0.00}" ]
You can also supply a Callback to the HoverTool, to build custom interactions on hover. In this case you may want to turn the tooltips off by setting tooltips=None.
tooltips=None
When supplying a callback or custom template, the explicit intent of this Bokeh Model is to embed raw HTML and JavaScript code for a browser to execute. If any part of the code is derived from untrusted user inputs, then you must take appropriate care to sanitize the user input prior to passing to Bokeh.
Hover tool does not currently work with the following glyphs:
annulus arc bezier image_url oval patch quadratic ray step text
annulus
arc
bezier
image_url
oval
patch
quadratic
ray
step
text
anchor
Enum(Anchor)
Anchor
'center'
If point policy is set to “snap_to_data”, anchor defines the attachment point of a tooltip. The default is to attach to the center of a glyph.
attachment
Enum(TooltipAttachment)
TooltipAttachment
'horizontal'
Whether the tooltip should be displayed to the left or right of the cursor position or above or below it, or if it should be automatically placed in the horizontal or vertical dimension.
A callback to run in the browser whenever the input’s value changes. The cb_data parameter that is available to the Callback code will contain two HoverTool specific fields:
cb_data
object containing the indices of the hovered points in the data source
object containing the coordinates of the hover cursor
formatters
Dict(String, Either(Enum(TooltipFieldFormatter), Instance(CustomJSHover)))
TooltipFieldFormatter
Specify the formatting scheme for data source columns, e.g.
tool.formatters = {"@date": "datetime"}
will cause format specifications for the “date” column to be interpreted according to the “datetime” formatting scheme. The following schemes are available:
Provides a wide variety of formats for numbers, currency, bytes, times, and percentages. The full set of formats can be found in the NumeralTickFormatter reference documentation.
NumeralTickFormatter
Provides formats for date and time values. The full set of formats is listed in the DatetimeTickFormatter reference documentation.
DatetimeTickFormatter
Provides formats similar to C-style “printf” type specifiers. See the PrintfTickFormatter reference documentation for complete details.
PrintfTickFormatter
If no formatter is specified for a column name, the default "numeral" formatter is assumed.
"numeral"
line_policy
Enum(Enumeration(prev, next, nearest, interp, none))
'nearest'
When showing tooltips for lines, designates whether the tooltip position should be the “previous” or “next” points on the line, the “nearest” point to the current mouse position, or “interpolate” along the line to the current mouse position.
Enum(Enumeration(mouse, hline, vline))
'mouse'
Whether to consider hover pointer as a point (x/y values), or a span on h or v directions.
muted_policy
Enum(Enumeration(show, ignore))
'show'
Whether to avoid showing tooltips on muted glyphs.
point_policy
Enum(Enumeration(snap_to_data, follow_mouse, none))
'snap_to_data'
Whether the tooltip position should snap to the “center” (or other anchor) position of the associated glyph, or always follow the current mouse cursor position.
show_arrow
Whether tooltip’s arrow should be shown.
Either(Null, String, List(Tuple(String, String)))
Null
Tuple
[('index', '$index'), ('data (x, y)', '($x, $y)'), ('screen (x, y)', '($sx, $sy)')]
The (name, field) pairs describing what the hover tool should display when there is a hit.
Field names starting with “@” are interpreted as columns on the data source. For instance, “@temp” would look up values to display from the “temp” column of the data source.
Field names starting with “$” are special, known fields:
index of hovered point in the data source
value of the name property of the hovered glyph renderer
x-coordinate under the cursor in data space
y-coordinate under the cursor in data space
x-coordinate under the cursor in screen (canvas) space
y-coordinate under the cursor in screen (canvas) space
color data from data source, with the syntax: $color[options]:field_name. The available options are: hex (to display the color as a hex value), swatch (color data from data source displayed as a small color box)
$color[options]:field_name
hex
swatch
color data from data source displayed as a small color box
Field names that begin with @ are associated with columns in a ColumnDataSource. For instance the field name "@price" will display values from the "price" column whenever a hover is triggered. If the hover is for the 17th glyph, then the hover tooltip will correspondingly display the 17th price value.
@
"@price"
"price"
Note that if a column name contains spaces, the it must be supplied by surrounding it in curly braces, e.g. @{adjusted close} will display values from a column named "adjusted close".
@{adjusted close}
"adjusted close"
Sometimes (especially with stacked charts) it is desirable to allow the name of the column be specified indirectly. The field name @$name is distinguished in that it will look up the name field on the hovered glyph renderer, and use that value as the column name. For instance, if a user hovers with the name "US East", then @$name is equivalent to @{US East}.
@$name
"US East"
@{US East}
By default, values for fields (e.g. @foo) are displayed in a basic numeric format. However it is possible to control the formatting of values more precisely. Fields can be modified by appending a format specified to the end in curly braces. Some examples are below.
@foo
"@foo{0,0.000}" # formats 10000.1234 as: 10,000.123 "@foo{(.00)}" # formats -10000.1234 as: (10000.123) "@foo{($ 0.00 a)}" # formats 1230974 as: $ 1.23 m
Specifying a format {safe} after a field name will override automatic escaping of the tooltip data source. Any HTML tags in the data tags will be rendered as HTML in the resulting HoverTool output. See Custom tooltip for a more detailed example.
{safe}
None is also a valid value for tooltips. This turns off the rendering of tooltips. This is mostly useful when supplying other actions on hover via the callback property.
The tooltips attribute can also be configured with a mapping type, e.g. dict or OrderedDict. However, if a dict is used, the visual presentation order is unspecified.
OrderedDict
{ "anchor": "center", "attachment": "horizontal", "callback": null, "description": null, "formatters": {}, "id": "19210", "js_event_callbacks": {}, "js_property_callbacks": {}, "line_policy": "nearest", "mode": "mouse", "muted_policy": "show", "name": null, "names": [], "point_policy": "snap_to_data", "renderers": "auto", "show_arrow": true, "subscribed_events": [], "syncable": true, "tags": [], "toggleable": true, "tooltips": [ [ "index", "$index" ], [ "data (x, y)", "($x, $y)" ], [ "screen (x, y)", "($sx, $sy)" ] ] }
InspectTool
A base class for tools that perform “inspections”, e.g. HoverTool.
{ "description": null, "id": "19231", "js_event_callbacks": {}, "js_property_callbacks": {}, "name": null, "subscribed_events": [], "syncable": true, "tags": [], "toggleable": true }
Inspection
alias of bokeh.models.tools.InspectTool
LassoSelectTool
The lasso selection tool allows users to make selections on a Plot by indicating a free-drawn “lasso” region by dragging the mouse or a finger over the plot region. The end of the drag event indicates the selection region is ready.
Selections can be comprised of multiple regions, even those made by different selection tools. Hold down the <<shift>> key while making a selection to append the new selection to any previous selection that might exist.
Instance(PolyAnnotation)
PolyAnnotation
PolyAnnotation(id='19249', ...)
Whether a selection computation should happen on every mouse event, or only once, when the selection region is completed.