Skip to content

Commit

Permalink
docs: Add new subsection content
Browse files Browse the repository at this point in the history
Not sure what the title should be, but @joelostblom proposed making this a new subsection

#3544 (review)
  • Loading branch information
dangotbanned committed Sep 18, 2024
1 parent fb42da7 commit 50a520e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions doc/user_guide/interactions/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,52 @@ we can change the order in which they are laid out via the following encoding::

You can see an example of this in the :ref:`gallery_selection_zorder` gallery example.

Untitled More When
^^^^^^^^^^^^^^^^^^
Simple conditions may be expressed without defining a default:

.. altair-plot::

source = data.cars()
brush = alt.selection_interval()
color = alt.when(brush).then("Origin")

points = (
alt.Chart(source)
.mark_point()
.encode(x="Horsepower", y="Miles_per_Gallon", color=color)
.add_params(brush)
)
points

Chain calls to express precise queries:

.. altair-plot::

source = data.cars()
color = (
alt.when(alt.datum.Miles_per_Gallon >= 30, Origin="Europe")
.then(alt.value("crimson"))
.when(alt.datum.Horsepower > 150)
.then(alt.value("goldenrod"))
.otherwise(alt.value("grey"))
)

points = (
alt.Chart(source)
.mark_point()
.encode(x="Horsepower", y="Miles_per_Gallon", color=color)
)
points

You can see more in :func:`when` and throughout many gallery examples:

- :ref:`gallery_dot_dash_plot`
- :ref:`gallery_multiline_tooltip_standard`
- :ref:`gallery_scatter_point_paths_hover`
- :ref:`gallery_waterfall_chart`


Filtering Data
^^^^^^^^^^^^^^

Expand Down

0 comments on commit 50a520e

Please sign in to comment.