from inspect_viz import Data
from inspect_viz.input import select
= Data.from_file("penguins.parquet")
penguins
="Species", column="species") select(penguins, label
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):
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):
="Species", column="species", value="auto") select(penguins, label
Here is a select input with explicit options (this input targets a Param):
from inspect_viz import Param
= Param("Apple")
fruit
="Fruit", options=["Apple", "Orange", "Banana"], target=fruit) select(label
Pass multiple=True
to enable multiple inputs. In this case values are specified via typing/autocomplete rather than a drop down menu.
= Data.from_file("athletes.parquet")
athletes
="Sports", column="sport", multiple=True) select(athletes, label
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
="Max Body Mass", column="body_mass") slider(penguins, label
Pass select="interval"
to specify an interval rather than single value:
="Body Mass Range", column="body_mass", select="interval") slider(penguins, label
Sliders can also target a Param and have explicit min
, max
, and step
values:
= Param(0.5)
bias
="Bias", min=0, max=1.0, step=0.1, target=bias) slider(label
Search
The search() input enables filtering a dataset based on text matching. For example, this input filters by WNBA player name
from inspect_viz.input import search
= Data.from_file("wnba-shots-2023.parquet")
players
="Athlete", column="athlete_name") search(players, label
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
= Param(True)
enabled
="Enabled", target=enabled) checkbox(label
Here we provide custom values that map to checked and unchecked states:
= Param(0.1)
bias
="Use Bias", values=[0.0, 0.1], target=bias) checkbox(label
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
= Data.from_file("penguins.parquet")
penguins
="Species", column="species") radio_group(penguins, label
Or targeting a Param:
= Param("Apple")
fruit
="Fruit", options=["Apple", "Orange", "Banana"], target=fruit) radio_group(label
Checkbox Group
The checkbox_group() provides an interface to select multiple values (similar to select(..., multiple=True)
):
from inspect_viz.input import checkbox_group
= Data.from_file("penguins.parquet")
penguins
="Species", column="species") checkbox_group(penguins, label
You can also use checkbox_group() with a Param:
= Param(["Apple", "Orange"])
fruit
="Fruit", options=["Apple", "Orange", "Banana"], target=fruit) checkbox_group(label