-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarifications to the interactive docs (#3362)
* Add example of selection in the foreground * Move and elaborate on encoding channel binding section * Add subtitles and clarifications to the expression section * Titles to title case and add one for the summary * Add dash-vega-components mention * Fix typo * Improve language * Add note about Altair tiles and example of interval geo selection * Add missing chart category * Clarify around facetting geo data * Fix typo * Fix typo * Add referenve to zorder gallery example * Minor clarification * Minor clarification * Fix typo
- Loading branch information
1 parent
60622e8
commit cbd9c9e
Showing
4 changed files
with
186 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Selection zorder | ||
================ | ||
This example shows how to bring selected points to the front/foreground | ||
by using a condition to change the point's (z)order | ||
as it is hovered over with the pointer. | ||
This prevents that the selected points are obscured | ||
by those that are not selected. | ||
""" | ||
# category: interactive charts | ||
|
||
import altair as alt | ||
from vega_datasets import data | ||
|
||
|
||
cars = data.cars.url | ||
|
||
hover = alt.selection_point(on='mouseover', nearest=True, empty=False) | ||
|
||
chart = alt.Chart(cars, title='Selection obscured by other points').mark_circle(opacity=1).encode( | ||
x='Horsepower:Q', | ||
y='Miles_per_Gallon:Q', | ||
color=alt.condition(hover, alt.value('coral'), alt.value('lightgray')), | ||
size=alt.condition(hover, alt.value(300), alt.value(30)) | ||
).add_params( | ||
hover | ||
) | ||
|
||
chart | chart.encode( | ||
order=alt.condition(hover, alt.value(1), alt.value(0)) | ||
).properties( | ||
title='Selection brought to front' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters