This docs on this page refers to a PREVIOUS VERSION. For the latest stable release, go to https://docs.bokeh.org/

Archived docs for versions <= 1.0.4 have had to be modified from their original published configuration, and may be missing some features (e.g. source listing)

All users are encourage to update to version 1.1 or later, as soon as they are able.

Bokeh Docs

bokeh.models.callbacks

Client-side interactivity.

class Callback(**kwargs)

Bases: bokeh.model.Model

Base class for interactive callback. Callback is generally not useful to instantiate on its own.

JSON Prototype
{
  "id": "1384a154-db46-4710-84b8-c0da61cf6492",
  "name": null,
  "tags": []
}
class CustomJS(**kwargs)

Bases: bokeh.models.callbacks.Callback

Execute a JavaScript function.

classmethod from_py_func(func)

Create a CustomJS instance from a Python function. The function is translated to Python using PyScript.

args

property type: 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

property type: code:String

A snippet of JavaScript/CoffeeScript code to execute in the browser. The code is made into the body of a function, and all of of the named objects in args are available as parameters that the code can use. Additionally, a cb_obj parameter contains the object that triggered the callback and an optional cb_data parameter that contains any tool-specific data (i.e. mouse coordinates and hovered glyph indices for the HoverTool).

lang

property type: lang:Enum(‘javascript’, ‘coffeescript’)

The implementation scripting language of the snippet. This can be either raw JavaScript or CoffeeScript. In CoffeeScript’s case, the snippet will be compiled at runtime (in a web browser), so you don’t need to have node.js/io.js, etc. installed.

JSON Prototype
{
  "args": {},
  "code": "",
  "id": "7d1829c8-8cd2-44d5-ac9a-e6e2f4a23827",
  "lang": "javascript",
  "name": null,
  "tags": []
}
class OpenURL(**kwargs)

Bases: bokeh.models.callbacks.Callback

Open a URL in a new tab or window (browser dependent).

url

property type: url:String

The URL to direct the web browser to. This can be a template string, which will be formatted with data from the data source.

JSON Prototype
{
  "id": "140afb6c-3638-423f-82a7-747ef53aa9c8",
  "name": null,
  "tags": [],
  "url": "http://"
}