Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Binder <[email protected]>
  • Loading branch information
joelostblom and binste authored Apr 8, 2024
1 parent 91017f1 commit f24c0d7
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
and assigns a lower order (0)
if there is a match.
The use of "indexOf" checks for equality in an array,
which here allows for mutliple segments to be reordered
which here allows for multiple segments to be reordered
by holding down the shift key while clicking the legend.
"""
# category: interactive charts
import altair as alt
from vega_datasets import data


selection = alt.selection_point(fields=['site'], bind='legend')

alt.Chart(data.barley.url).mark_bar().transform_calculate(
source = data.barley.url

alt.Chart(source).mark_bar().transform_calculate(
site_order=f"if({selection.name}.site && indexof({selection.name}.site, datum.site) !== -1, 0, 1)"
).encode(
x='sum(yield):Q',
Expand Down

0 comments on commit f24c0d7

Please sign in to comment.