comparisons#
Represent comparisons to be computed on the client (browser) side by BokehJS. These comparisons may be useful for specifying how DataTable columns are sorted.
- class Comparison(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
- Base class for
Comparisonmodels that represent a comparison to be carried out on the client-side.
The JavaScript implementation should implement the following method:
compute(x: unknown, y: unknown): -1 | 0 | 1 { // compare and return -1, 0, or 1 }
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.
- Base class for
- class CustomJSCompare(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
A client-side comparison performed by evaluating a user-supplied JavaScript function. This comparison can be useful for DataTable columns.
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#
A mapping of names to Python objects. In particular those can be bokeh’s models. These objects are made available to the callback’s code snippet as the values of named parameters to the callback. There is no need to manually include the data source of the associated glyph renderer, as it is available within the scope of the code via this keyword (e.g. this.data will give access to raw data).
- code#
A snippet of JavaScript code to execute in the browser. The code is made into the body of a generator function and all of the named objects in
argsare available as parameters that the code can use. Must return -1, 0, or 1.