Skip to content

Commit

Permalink
Minor docs and dev/app.py changes
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-qb committed May 24, 2024
1 parent d13a060 commit ff5504b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vizro-core/docs/pages/user-guides/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ You can supply arguments to your dynamic data loading function that can be modif

To add a parameter to control a dynamic data source, do the following:

- add the appropriate argument to your dynamic data function and specify a default value for the argument.
- give an `id` to all components that have the data source you wish to alter through a parameter.
- [add a parameter](parameters.md) with `targets` of the form `<target_component_id>.data_frame.<dynamic_data_argument>` and a suitable [selector](selectors.md).
1. add the appropriate argument to your dynamic data function and specify a default value for the argument.
2. give an `id` to all components that have the data source you wish to alter through a parameter.
3. [add a parameter](parameters.md) with `targets` of the form `<target_component_id>.data_frame.<dynamic_data_argument>` and a suitable [selector](selectors.md).

For example, let us extend the [dynamic data example](#dynamic-data) above to show how the `load_iris_data` can take an argument `number_of_points` controlled from the dashboard with a [`Slider`][vizro.models.Slider].

Expand Down Expand Up @@ -328,7 +328,7 @@ Parametrized data loading is compatible with [caching](#configure-cache). The ca

!!! warning

You should always [treat the content of user input as untrusted](https://community.plotly.com/t/writing-secure-dash-apps-community-thread/54619). For example, you should not expose as a parameter a filepath to load without passing it through a function like [`werkzeug.utils.secure_filename`](https://werkzeug.palletsprojects.com/en/3.0.x/utils/#werkzeug.utils.secure_filename); otherwise you might enable a user to access arbitrary files on your server.
You should always [treat the content of user input as untrusted](https://community.plotly.com/t/writing-secure-dash-apps-community-thread/54619). For example, you should not expose a filepath to load without passing it through a function like [`werkzeug.utils.secure_filename`](https://werkzeug.palletsprojects.com/en/3.0.x/utils/#werkzeug.utils.secure_filename), or you might enable arbitrary access to files on your server.

It is not possible to pass [nested parameters](parameters.md#nested-parameters) to dynamic data. You can only target top-level arguments of the data loading function and not address nested keys in a dictionary.

Expand Down
3 changes: 3 additions & 0 deletions vizro-core/examples/_dev/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def load_iris_data(points=1, additional_points=1):

data_manager["iris"] = load_iris_data

# If you want to cache the data on the page_2 differently from page_1, you can define another data_manager entry with
# the same function and assign it to the page_2 graphs. e.g. `data_manager["iris_2"] = load_iris_data`

# SimpleCache
data_manager.cache = Cache(config={"CACHE_TYPE": "SimpleCache"})

Expand Down

0 comments on commit ff5504b

Please sign in to comment.