Inputs

Inputs are used to create interactive visualisations by targeting either Param values or Selection ranges. Available inputs include:

All inputs can write updates to a provided Param or Selection. Param values are updated to match the input value. Selections are provided a predicate clause. This linking can be bidirectional: an input component will also subscribe to a param and track its value updates.

Select

The select() input is used to select one more more values from a list. The list can be sourced from a data column (via the column parameter) or be static (via the options parameter). Here is a select input bound to a column (this input targets the default Selection associated with the passed Data):

from inspect_viz import Data
from inspect_viz.input import select

penguins = Data.from_file("penguins.parquet")

select(penguins, label="Species", column="species")

Note that by default the select has no value so does not filtering (represented by the default “All” selection). If you want a select() to have an initial value then specify it using the value parameter (or pass ‘auto’ to select the first value):

select(penguins, label="Species", column="species", value="auto")

Here is a select input with explicit options (this input targets a Param):

from inspect_viz import Param

fruit = Param("Apple")

select(label="Fruit", options=["Apple", "Orange", "Banana"], target=fruit)

Pass multiple=True to enable multiple inputs. In this case values are specified via typing/autocomplete rather than a drop down menu.

athletes = Data.from_file("athletes.parquet")

select(athletes, label="Sports", column="sport", multiple=True)

Slider

The slider() input enables specificiation of either a single numeric value or a range of values. Here we enable the selection of a maximum body mass for a column:

from inspect_viz.input import slider

slider(penguins, label="Max Body Mass", column="body_mass")

Pass select="interval" to specify an interval rather than single value:

slider(penguins, label="Body Mass Range", column="body_mass", select="interval")

Sliders can also target a Param and have explicit min, max, and step values:

bias = Param(0.5)

slider(label="Bias", min=0, max=1.0, step=0.1, target=bias)

Checkbox

The checkbox() input enables toggling a binary value. You can either target boolean Param values or provide custom values mapped to checked and unchecked.

from inspect_viz.input import checkbox

enabled = Param(True)

checkbox(label="Enabled", target=enabled)

Here we provide custom values that map to checked and unchecked states:

bias = Param(0.1)

checkbox(label="Use Bias", values=[0.0, 0.1], target=bias)

Radio Group

The radio_group() is an alternative to select() which displays all of the available options rather than collapsing them into a menu:

from inspect_viz.input import radio_group

penguins = Data.from_file("penguins.parquet")

radio_group(penguins, label="Species", column="species")

Or targeting a Param:

fruit = Param("Apple")

radio_group(label="Fruit", options=["Apple", "Orange", "Banana"], target=fruit)

Checkbox Group

The checkbox_group() provides an interface to select multiple values (similar to select(..., multiple=True)):

from inspect_viz.input import checkbox_group

penguins = Data.from_file("penguins.parquet")

checkbox_group(penguins, label="Species", column="species")

You can also use checkbox_group() with a Param:

fruit = Param(["Apple", "Orange"])

checkbox_group(label="Fruit", options=["Apple", "Orange", "Banana"], target=fruit)