Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/dynamic filter #879

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft

Feat/dynamic filter #879

wants to merge 37 commits into from

Conversation

petar-qb
Copy link
Contributor

Description

Screenshot

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.
    • I have not referenced individuals, products or companies in any commits, directly or indirectly.
    • I have not added data or restricted code in any commits, directly or indirectly.

antonymilne and others added 29 commits November 4, 2024 10:52
# Conflicts:
#	vizro-core/src/vizro/models/_controls/filter.py
…_manager to the Filter.pre_build data_manager _multi_load
@github-actions github-actions bot added the Vizro-AI 🤖 Issue/PR that addresses Vizro-AI package label Nov 15, 2024
Copy link
Contributor

github-actions bot commented Nov 15, 2024

View the example dashboards of the current commit live on PyCafe ☕ 🚀

Updated on: 2024-11-15 13:53:42 UTC
Commit: b912bb0

Link: vizro-core/examples/dev/

Link: vizro-core/examples/scratch_dev

Link: vizro-core/examples/visual-vocabulary/

Link: vizro-ai/examples/dashboard_ui/

Comment on lines +1 to +13
# Choose from 0-50
setosa: 5
versicolor: 10
virginica: 15

# Choose from: 4.8 to 7.4
min: 5
max: 7

# Choose from:
# 2020-01-01 to 2020-05-29
date_min: 2024-01-01
date_max: 2024-05-29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusting these values, the input data is changed for the scratch/app.py example.

Comment on lines +262 to +281
control_targets = []
control_targets_targets = []
figure_targets = []
for target in targets:
target_obj = model_manager[target]
if isinstance(target_obj, Filter):
control_targets.append(target)
control_targets_targets.extend(target_obj.targets)
else:
figure_targets.append(target)

# Retrieving only figure_targets data_frames from _multi_load is not the best solution.
# In that way, we assume that Filter.targets are the subset of the action's targets. This works for the
# on_page_load, but will not work if targets are explicitly set.
# For example, in future, if Parameter is targeting only a single Filter.
_get_unfiltered_data_targets = list(set(figure_targets + control_targets_targets))

figure_targets_unfiltered_data: dict[ModelID, pd.DataFrame] = _get_unfiltered_data(
ctds_parameter=ctds_parameter, targets=_get_unfiltered_data_targets
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this code can be removed. It's here only to support future cases like when the dynamic Filter is the Parameter direct target.

@@ -22,9 +22,15 @@ def _on_page_load(targets: list[ModelID], **inputs: dict[str, Any]) -> dict[Mode
Dict mapping target chart ids to modified figures e.g. {'my_scatter': Figure({})}
"""
return _get_modified_page_figures(
print("\nON PAGE LOAD - START")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to myself to remove all print statements before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vizro-AI 🤖 Issue/PR that addresses Vizro-AI package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants