Skip to content

Commit

Permalink
Docs: Change "multiple interactions" to use a nominal scale and adjus…
Browse files Browse the repository at this point in the history
…ted sizes (vega#3350)

* Update multiple_interactions.py

* Simplify logic

---------

Co-authored-by: Joel Ostblom <[email protected]>
  • Loading branch information
d-trigo and joelostblom authored Mar 6, 2024
1 parent 3ac2021 commit f593927
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tests/examples_methods_syntax/multiple_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
* Dropdown: Filters the movies by genre
* Radio Buttons: Highlights certain films by Worldwide Gross
* Mouse Drag and Scroll: Zooms the x and y scales to allow for panning.
* Mouse Drag and Scroll: Zooms the x and y scales to allow for panning
* Checkbox: Scales the marker size of big budget films
"""
# category: interactive charts
Expand All @@ -27,8 +26,8 @@

base = alt.Chart(movies, width=200, height=200).mark_point(filled=True).transform_calculate(
Rounded_IMDB_Rating = "floor(datum.IMDB_Rating)",
Hundred_Million_Production = "datum.Production_Budget > 100000000.0 ? 100 : 10",
Release_Year = "year(datum.Release_Date)"
Big_Budget_Film = "datum.Production_Budget > 100000000 ? 'Yes' : 'No'",
Release_Year = "year(datum.Release_Date)",
).transform_filter(
alt.datum.IMDB_Rating > 0
).transform_filter(
Expand Down Expand Up @@ -59,7 +58,7 @@
genre_select
).properties(title="Dropdown Filtering")

#color changing marks
# Color changing marks
rating_radio = alt.binding_radio(options=ratings, name="Rating")
rating_select = alt.selection_point(fields=['MPAA_Rating'], bind=rating_radio)

Expand All @@ -81,7 +80,7 @@

size_checkbox_condition = alt.condition(
checkbox_selection,
alt.Size('Hundred_Million_Production:Q'),
alt.Size('Big_Budget_Film:N').scale(range=[25, 150]),
alt.SizeValue(25)
)

Expand All @@ -91,4 +90,4 @@
size=size_checkbox_condition
).properties(title="Checkbox Formatting")

(filter_year | filter_genres) & (highlight_ratings | budget_sizing)
(filter_year | budget_sizing) & (highlight_ratings | filter_genres)

0 comments on commit f593927

Please sign in to comment.