Actions
vizro.actions
Built-in actions, typically aliased as va using import vizro.actions as va.
Usage documentation
export_data
Exports data of target charts, tables and figures.
Usage documentation
Parameters:
-
targets() –list [ModelID ]List of target component ids for which to download data. If none are given then download data from all components on the page.
-
file_format() –Literal ['csv', 'xlsx']Format of downloaded files. Defaults to
"csv".
Example
filter_interaction
deprecated
Deprecated
filter_interaction is deprecated and will not exist in Vizro 0.2.0. Use the more powerful and flexible [set_control][vizro.actions.set_control].
Filters targeted graph, tables and figures when a source graph or table is clicked.
Parameters:
-
targets() –list [ModelID ]Target component to be affected by filter. If none are given then target all valid components on the page.
set_control
Sets the value of a control, which then updates its targets.
Usage documentation
The following Vizro models can be a source of set_control:
- [
AgGrid][vizro.models.AgGrid]: triggersset_controlwhen user clicks on a row in the table.valueis string specifying which column in the clicked row is used to setcontrol. -
[
Graph][vizro.models.Graph]: triggersset_controlwhen user clicks on data in the graph.valueis string that can be used in two ways to specify how to setcontrol:- Column from which to take the value. This requires you to set
custom_datain the graph'sfigurefunction. - String to traverse a Box that contains the
trigger data
clickData["points"][0]. This is typically useful for a positional variable, for example"x", and does not require settingcustom_data.
- Column from which to take the value. This requires you to set
-
[
Figure][vizro.models.Figure]: triggersset_controlwhen user clicks on the figure.valuespecifies a literal value to setcontrolto. - [
Button][vizro.models.Button]: triggersset_controlwhen user clicks on the button.valuespecifies a literal value to setcontrolto. - [
Card][vizro.models.Card]: triggersset_controlwhen user clicks on the card.valuespecifies a literal value to setcontrolto.
Parameters:
-
control() –ModelID Control whose value is set. If this is on a different page from the trigger then it must have
show_in_url=True. The control's selector must be categorical (e.g. Dropdown, RadioItems, Checklist). -
value() –JsonValue Value taken from trigger to set
control. Format depends on the source model that triggersset_control.
AgGrid as trigger
Graph as trigger with custom_data
Graph as trigger without custom_data
Figure as trigger
Button as trigger
Card as trigger
show_notification
Shows a notification message.
Usage documentation
Parameters:
-
text() –str Markdown text for the main notification message. Follows the CommonMark specification.
-
variant() –Literal ['info', 'success', 'warning', 'error', 'progress']Variant that determines color and default icon. If
progress, the notification will show a loading spinner instead of an icon. Defaults to "info". -
title() –str Notification title. Set to
""to hide the title. Defaults to the capitalized variant name, for example"Info"forvariant="info". -
icon() –str Icon name from the Google Material Icon Library. Ignored if
variant="progress". Defaults to the variant-specific icon, for example 'info' for 'info' variant. -
auto_close() –bool |int Auto-close duration in milliseconds. Set to
Falseto keep the notification open until the user closes it manually. Default value depends on variant:4000for info/success/warning/error,Falsefor progress.
Example
update_notification
Updates an existing notification message.
This action updates notifications that were previously created with
[show_notification][vizro.actions.show_notification]. notification must match the id of the original
show_notification action.
Usage documentation
Parameters:
-
notification() –ModelID Notification to update. Must match the id of the original
show_notificationaction. -
text() –str Markdown text for the main notification message. Follows the CommonMark specification.
-
variant() –Literal ['info', 'success', 'warning', 'error', 'progress']Variant that determines color and default icon. If
progress, the notification will show a loading spinner instead of an icon. Defaults to "info". -
title() –str Notification title. Set to
""to hide the title. Defaults to the capitalized variant name, for example"Info"forvariant="info". -
icon() –str Icon name from the Google Material Icon Library. Ignored if
variant="progress". Defaults to the variant-specific icon, for example 'info' for 'info' variant. -
auto_close() –bool |int Auto-close duration in milliseconds. Set to
Falseto keep the notification open until the user closes it manually. Default value depends on variant:4000for info/success/warning/error,Falsefor progress.
Example
```python import vizro.actions as va import vizro.models as vm
vm.Button( text="Save", actions=[ va.show_notification(id="save_notification", text="Saving data...", variant="progress"), va.export_data(), va.update_notification( notification="save_notification", text="Data saved successfully!", variant="success" ), ], )
```