Skip to content

Actions

API reference for all pre-defined action functions.

vizro.actions

export_data

export_data(targets=None, file_format='csv', **inputs)

Exports visible data of target charts/components on page after being triggered.

Parameters:

  • targets (Optional[List[ModelID]], default: None ) –

    List of target component ids to download data from. Defaults to None.

  • file_format (Literal['csv', 'xlsx'], default: 'csv' ) –

    Format of downloaded files. Defaults to csv.

  • inputs (Dict[str, Any], default: {} ) –

    Dict mapping action function names with their inputs e.g. inputs = {'filters': [], 'parameters': ['gdpPercap'], 'filter_interaction': [], 'theme_selector': True}

Raises:

  • ValueError

    If unknown file extension is provided.

  • ValueError

    If target component does not exist on page.

Returns:

  • Dict mapping target component id to modified charts/components e.g. {'my_scatter'

    Figure({})}

filter_interaction

filter_interaction(targets=None, **inputs)

Filters targeted charts/components on page by clicking on data points or table cells of the source chart.

To set up filtering on specific columns of the target graph(s), include these columns in the 'custom_data' parameter of the source graph e.g. px.bar(..., custom_data=["species", "sepal_length"]). If the filter interaction source is a table e.g. vm.Table(..., actions=[filter_interaction]), then the table doesn't need to have a 'custom_data' parameter set up.

Parameters:

  • targets (Optional[List[ModelID]], default: None ) –

    List of target component ids to filter by chart interaction. If missing, will target all valid components on page. Defaults to None.

  • inputs (Dict[str, Any], default: {} ) –

    Dict mapping action function names with their inputs e.g. inputs = {'filters': [], 'parameters': ['gdpPercap'], 'filter_interaction': [], 'theme_selector': True}

Returns:

  • Dict mapping target component ids to modified charts/components e.g. {'my_scatter'

    Figure({})}