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

Deprecate .ref() instead of removing it #3063

Merged
merged 6 commits into from
May 19, 2023

Conversation

mattijn
Copy link
Contributor

@mattijn mattijn commented May 19, 2023

Fix #3059.

This PR reintroduce the .ref() function which was removed in Altair 5.0.0.

While the function is not needed anymore it is better to deprecate first to ease transition.

Now the following from the Altair Tutorial on selections:

import altair as alt
from vega_datasets import data

weather = data.seattle_weather()

interval = alt.selection_interval(encodings=['x'])

base = alt.Chart(weather).mark_rule(size=2).encode(
    x='date:T',
    y='temp_min:Q',
    y2='temp_max:Q',
    color='weather:N'
)

chart = base.encode(
    x=alt.X('date:T', scale=alt.Scale(domain=interval.ref()))
).properties(
    width=800,
    height=300
)

view = base.add_selection(
    interval
).properties(
    width=800,
    height=50,
)

chart & view
d:\Software\mattijn\altair\altair\utils\deprecation.py:65: AltairDeprecationWarning: 'ref' is deprecated. No need to call '.ref()' anymore.
  warnings.warn(message, AltairDeprecationWarning, stacklevel=1)
d:\Software\mattijn\altair\altair\utils\deprecation.py:65: AltairDeprecationWarning: 'add_selection' is deprecated. Use 'add_params' instead.
  warnings.warn(message, AltairDeprecationWarning, stacklevel=1)

And a working plot.
image

Copy link
Contributor

@binste binste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Only one minor comment.

doc/releases/changes.rst Outdated Show resolved Hide resolved
Co-authored-by: Stefan Binder <binder_stefan@outlook.com>
@mattijn mattijn merged commit 5d15325 into vega:master May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: 'GetAttrExpression' object is not callable with interval.ref()
2 participants