Skip to content

Commit 8fdd537

Browse files
authored
docs: Add initial date range to interval selection example (#3667)
1 parent 64b2d33 commit 8fdd537

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

tests/examples_arguments_syntax/interval_selection.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
"""
2-
Interval Selection
3-
==================
2+
Interval Selection with Initial Date Range
3+
==========================================
44
55
This is an example of creating a stacked chart for which the domain of the
6-
top chart can be selected by interacting with the bottom chart.
6+
top chart can be selected by interacting with the bottom chart. The initial
7+
selection range is set using Python's native datetime objects.
78
"""
8-
# category: area charts
9+
# category: interactive charts
910
import altair as alt
1011
from vega_datasets import data
12+
import datetime as dt
1113

1214
source = data.sp500.url
1315

14-
brush = alt.selection_interval(encodings=['x'])
16+
date_range = (dt.date(2007, 6, 30), dt.date(2009, 6, 30))
17+
18+
brush = alt.selection_interval(encodings=['x'],
19+
value={'x': date_range})
1520

1621
base = alt.Chart(source).mark_area().encode(
1722
x = 'date:T',

tests/examples_methods_syntax/interval_selection.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
"""
2-
Interval Selection
3-
==================
2+
Interval Selection with Initial Date Range
3+
==========================================
44
55
This is an example of creating a stacked chart for which the domain of the
6-
top chart can be selected by interacting with the bottom chart.
6+
top chart can be selected by interacting with the bottom chart. The initial
7+
selection range is set using Python's native datetime objects.
78
"""
8-
# category: area charts
9+
# category: interactive charts
910
import altair as alt
1011
from vega_datasets import data
12+
import datetime as dt
1113

1214
source = data.sp500.url
1315

14-
brush = alt.selection_interval(encodings=['x'])
16+
date_range = (dt.date(2007, 6, 30), dt.date(2009, 6, 30))
17+
18+
brush = alt.selection_interval(encodings=['x'],
19+
value={'x': date_range})
1520

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

0 commit comments

Comments
 (0)