bokeh.models.filters¶
-
class
BooleanFilter(*args, **kw)[source]¶ Bases:
bokeh.models.filters.FilterA
BooleanFilterfilters data by returning the subset of data corresponding to indices where the values of the booleans array is True.
-
class
CustomJSFilter(*args, **kw)[source]¶ Bases:
bokeh.models.filters.FilterFilter data sources with a custom defined JavaScript function.
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¶ property type:
Dict(String,AnyRef)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.
-
code¶ property type:
StringA snippet of JavaScript code to filter data contained in a columnar data source. The code is made into the body of a function, and all of of the named objects in
argsare available as parameters that the code can use. The variablesourcewill contain the data source that is associated with theCDSViewthis filter is added to.The code should either return the indices of the subset or an array of booleans to use to subset data source rows.
Example:
code = ''' var indices = []; for (var i = 0; i <= source.data['some_column'].length; i++){ if (source.data['some_column'][i] == 'some_value') { indices.push(i) } } return indices; '''
Note
Use
CustomJS.from_coffeescript()for CoffeeScript source code.
-
classmethod
from_coffeescript(code, args={})[source]¶ Create a
CustomJSFilterinstance from CoffeeScript snippets. The function bodies are translated to JavaScript functions using node and therefore require return statements.The
codefunction namespace will contain the variablesourceat render time. This will be the data source associated with theCDSViewthat this filter is added to.
-
classmethod
from_py_func(func)[source]¶ Create a
CustomJSFilterinstance from a Python function. The function is translated to JavaScript using PScript.The
funcfunction namespace will contain the variablesourceat render time. This will be the data source associated with theCDSViewthat this filter is added to.
-
-
class
Filter(*args, **kw)[source]¶ Bases:
bokeh.model.ModelA Filter model represents a filtering operation that returns a row-wise subset of data when applied to a
ColumnDataSource.
-
class
GroupFilter(*args, **kw)[source]¶ Bases:
bokeh.models.filters.FilterA
GroupFilterrepresents the rows of aColumnDataSourcewhere the values of the categorical column column_name match the group variable.