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

docs: Add initial date range to interval selection example #3667

Merged
merged 8 commits into from
Nov 3, 2024
13 changes: 9 additions & 4 deletions tests/examples_arguments_syntax/interval_selection.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
"""
Interval Selection
==================
Interval Selection with Initial Date Range
==========================================

This is an example of creating a stacked chart for which the domain of the
top chart can be selected by interacting with the bottom chart.
top chart can be selected by interacting with the bottom chart. The initial
selection range is set using Python's native datetime objects.
"""
# category: area charts
mattijn marked this conversation as resolved.
Show resolved Hide resolved
import altair as alt
from vega_datasets import data
import datetime as dt

source = data.sp500.url

brush = alt.selection_interval(encodings=['x'])
date_range = (dt.date(2007, 6, 30), dt.date(2009, 6, 30))

brush = alt.selection_interval(encodings=['x'],
value={'x': date_range})

base = alt.Chart(source).mark_area().encode(
x = 'date:T',
Expand Down
13 changes: 9 additions & 4 deletions tests/examples_methods_syntax/interval_selection.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
"""
Interval Selection
==================
Interval Selection with Initial Date Range
==========================================

This is an example of creating a stacked chart for which the domain of the
top chart can be selected by interacting with the bottom chart.
top chart can be selected by interacting with the bottom chart. The initial
selection range is set using Python's native datetime objects.
"""
# category: area charts
mattijn marked this conversation as resolved.
Show resolved Hide resolved
import altair as alt
from vega_datasets import data
import datetime as dt

source = data.sp500.url

brush = alt.selection_interval(encodings=['x'])
date_range = (dt.date(2007, 6, 30), dt.date(2009, 6, 30))

brush = alt.selection_interval(encodings=['x'],
value={'x': date_range})

base = alt.Chart(source, width=600, height=200).mark_area().encode(
x = 'date:T',
Expand Down