Skip to content

Filters

Filters that narrow a pipeline, used in YAML specs and Python.

lumen.filters

base

The Filter components supply query parameters used to filter the tables returned by a Source.

BaseDateFilter

Bases: BaseWidgetFilter

mode = param.Selector(default='slider', objects=['slider', 'picker'], doc='\n Whether to use a slider or a picker.') class-attribute instance-attribute
multi = param.Boolean(default=True, doc='\n Whether to use a single-value or multi-value/range selection widget.') class-attribute instance-attribute
panel property
query property
throttled = param.Boolean(default=True, doc='\n Whether to throttle slider value changes.') class-attribute instance-attribute
widget = widget_type(**(self._widget_kwargs(as_date=(self._as_date)))) instance-attribute

BaseWidgetFilter

Bases: Filter

default = param.Parameter(doc='\n The default value to use on the widget.') class-attribute instance-attribute
disabled = param.Boolean(default=False, doc='\n Whether the filter should be disabled.') class-attribute instance-attribute
panel property
throttled = param.Boolean(default=True, doc='\n If the widget has a value_throttled parameter use that instead,\n ensuring that no intermediate events are generated, e.g. when\n dragging a slider.') class-attribute instance-attribute
visible = param.Boolean(default=True, doc='\n Whether the filter should be visible.') class-attribute instance-attribute
widget = None instance-attribute

BinFilter

Bases: BaseWidgetFilter

BinFilter is a special WidgetFilter that allows selecting from a set of bins.

The bins must be declared from a list of tuples declaring the lower- and upper-bound of each bin and an optional set of labels of the same length.

bins = param.List(default=[], constant=True, doc='\n A list of bins expressed as length two tuples.') class-attribute instance-attribute
empty_select = param.Boolean(default=True, doc='\n Add an option to Select widgets to indicate no filtering.') class-attribute instance-attribute
filter_type = 'bins' class-attribute
labels = param.List(default=None, constant=True, doc='\n A list of labels for each bin (optional).') class-attribute instance-attribute
multi = param.Boolean(default=True, doc='\n Whether to use a single-value or multi-value selection widget.') class-attribute instance-attribute
query property
widget = widget(label=(self.label), options=options, value=value) instance-attribute

ConstantFilter

Bases: Filter

The ConstantFilter allows requesting a constant value from the Source.

filter_type = 'constant' class-attribute
panel property
query property

DateFilter

Bases: BaseDateFilter

DateFilter is a WidgetFilter specialized to select calendar dates.

Depending on whether multi selection is enabled a single date or range of dates can be selected with a DatePicker or DateRangeSlider respectively.

filter_type = 'date' class-attribute

DatetimeFilter

Bases: BaseDateFilter

DatetimeFilter is a WidgetFilter specialized to filter by datetimes.

Depending on whether multi selection is enabled a single date or range of dates can be selected with a DatetimePicker or DatetimeRangeSlider respectively.

filter_type = 'datetime' class-attribute

FacetFilter

Bases: Filter

The FacetFilter allows faceting the data along some dimension to allow a single View to be exploded into multiple by grouping over one of the indexes.

filter_type = 'facet' class-attribute instance-attribute
filters property

Filter

Bases: MultiTypeComponent

Filter components supply the filter values used by Source components to query data. .

field = param.String(doc='The field being filtered.') class-attribute instance-attribute
filter_type = None class-attribute
label = param.String(doc='A label for the Filter.') class-attribute instance-attribute
panel property

Returns:

Type Description
Viewable or None

A Panel Viewable object representing the filter.

query property

Returns:

Type Description
object

The current filter query which will be used by the Source to filter the data.

schema = param.Dict(doc='\n The JSON schema provided by the Source declaring information\n about the data to be filtered.') class-attribute instance-attribute
shared = param.Boolean(default=False, doc='\n Whether the filter is shared across all layouts.') class-attribute instance-attribute
sync_with_url = param.Boolean(default=True, doc='\n Whether to sync the filter state with the URL parameters.') class-attribute instance-attribute
table = param.String(default=None, doc='\n The table being filtered. If None applies to all tables.') class-attribute instance-attribute
value = param.Parameter(doc='The current filter value.') class-attribute instance-attribute
from_spec(spec, source_schema, source_filters=None) classmethod

Resolves a Filter specification given the schema of the Source (and optionally the table) it will be filtering on.

Parameters:

Name Type Description Default
spec dict[str, Any] | str

Specification declared as a dictionary of parameter values.

required
source_schema dict[str, dict[str, Any]]

A dictionary containing the JSON schema of the Source to be filtered on.

required
source_filters dict[str, Filter] | None

A dictionary of filters associated with the Source

None

Returns:

Type Description
The resolved Filter object.
to_spec(context=None)
validate(spec, context=None) classmethod

ParamFilter

Bases: Filter

ParamFilter reflects the value of a parameter declared on a View.

The ParamFilter can be used to implement cross-filtering between different views.

filter_type = 'param' class-attribute
parameter = param.ClassSelector(default=None, class_=(param.Parameter, str), doc='\n Reference to a Parameter on an existing View.') class-attribute instance-attribute

WidgetFilter

Bases: BaseWidgetFilter

WidgetFilter generates a Widget from the table schema provided by a Source.

By default the widget type will be inferred from the data and depending on whether multi value selection is enabled.

empty_select = param.Boolean(default=True, doc='\n Add an option to Select widgets to indicate no filtering.') class-attribute instance-attribute
filter_type = 'widget' class-attribute
max_options = param.Integer(default=500, doc='\n Maximum number of options to render.') class-attribute instance-attribute
multi = param.Boolean(default=True, doc='\n Whether to use a single-value or multi-value selection widget,\n e.g. for a numeric value this could be a regular slider or a\n range slider.') class-attribute instance-attribute
query property
value = self.default instance-attribute
widget = JSONSchema(schema=(self.schema), sizing_mode='stretch_width', multi=(self.multi), widgets=({self.field: wtype} if wtype else {}))._widgets[self.field] class-attribute instance-attribute
to_spec(context=None)