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

Add support for selections to st.altair_chart & st.vega_lite_chart #8302

Merged
merged 354 commits into from May 14, 2024

Conversation

willhuang1997
Copy link
Collaborator

@willhuang1997 willhuang1997 commented Mar 14, 2024

Describe your changes

Adds selection support to st.altair_chart and st.vega_lite_chart that can be used via:

selections = st.altair_chart(fig, on_select="rerun")

GitHub Issue Link (if applicable)

Testing Plan

  • Added unit tests
  • Added e2e tests

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@willhuang1997 willhuang1997 marked this pull request as ready for review March 25, 2024 19:42
@willhuang1997 willhuang1997 marked this pull request as draft March 25, 2024 19:42
@willhuang1997 willhuang1997 marked this pull request as ready for review April 1, 2024 18:42
@willhuang1997 willhuang1997 marked this pull request as draft April 1, 2024 18:43
@sfc-gh-wihuang sfc-gh-wihuang changed the base branch from feature/InteractiveCharts_Plotly to develop April 15, 2024 18:49
@sfc-gh-wihuang sfc-gh-wihuang changed the base branch from develop to feature/InteractiveCharts_Plotly April 15, 2024 18:50
Copy link
Collaborator

@raethlein raethlein left a comment

Choose a reason for hiding this comment

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

It's a big PR and we have chatted offline about the fact that it would make sense to migrate the class component to a functional one and in general clean it up and refactor it more. Though, that can be a follow-up.

@LukasMasuch LukasMasuch changed the title [WIP] Add support for selections to st.altair_chart & st.vega_lite_chart Add support for selections to st.altair_chart & st.vega_lite_chart May 14, 2024
@@ -236,7 +236,7 @@ def _test_shift_click_point_selection_scatter_chart_displays_selection(
app.wait_for_timeout(100)

expected_prefix = "Scatter chart with selection_point:"
expected_selection = "\\{'select': \\{'param_1': \\[\\{'Origin': 'USA', 'Horsepower': 88, 'Miles_per_Gallon': 20\\.2\\}, \\{'Origin': 'USA', 'Horsepower': 110, 'Miles_per_Gallon': 18\\.6\\}, \\{'Origin': 'USA', 'Horsepower': 150, 'Miles_per_Gallon': 14\\}, \\{'Origin': 'Japan', 'Horsepower': 52, 'Miles_per_Gallon': 32\\.8\\}\\]\\}\\}"
expected_selection = "\\{'select': \\{'param_1': \\[\\{'Origin': 'USA', 'Horsepower': (88|90), 'Miles_per_Gallon': 20\\.2\\}, \\{'Origin': 'USA', 'Horsepower': 110, 'Miles_per_Gallon': 18\\.6\\}, \\{'Origin': 'USA', 'Horsepower': 150, 'Miles_per_Gallon': 1(4|5)\\}, \\{'Origin': 'Japan', 'Horsepower': 52, 'Miles_per_Gallon': 32\\.8\\}\\]\\}\\}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@raethlein We could also just check if there is any number in the value. I think for the test it doesn't really matter what kind of number is in there ... we just want to make sure that selecting an area works and returns an area selection.

Changes to the vega rendering might also easily apply small rendering changes so that the same selection leads to slightly different areas.

@LukasMasuch LukasMasuch merged commit 11484df into develop May 14, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants