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

Transform filter from selection of temporal data is empty #828

Closed
gschivley opened this issue May 10, 2018 · 8 comments
Closed

Transform filter from selection of temporal data is empty #828

gschivley opened this issue May 10, 2018 · 8 comments
Labels
bug vega: vega-lite Requires upstream action in `vega-lite`

Comments

@gschivley
Copy link

I'm trying to use selection_interval to show a histogram of values selected from a scatterplot. This works fine with quantitative data but fails with temporal data that has not been transformed.

import altair as alt
import pandas as pd
import numpy as np

# Make dataframe from datetimes, random values, and sequential counts
dates = pd.date_range(start='1-1-2017-01', periods=200, freq='H')
values = np.random.randint(0, 20, size=200)
count = range(len(dates))

data = pd.DataFrame({'dt': dates, 'values': values, 'count': count})

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

points = alt.Chart(data).mark_point().encode(
# Unmodified datetime, counts, and transformed datatime data for the x-axis
    x='dt:T',
#     x='count:Q',
#     x=alt.X('dt:T', timeUnit='yearmonthdatehours', axis=alt.Axis(title='Transformed dt')),
    y='values:Q',
).properties(
    selection=brush
)

bars = alt.Chart(data).mark_bar().encode(
    x='values:Q',
    y='count()'
).transform_filter(
    brush.ref()
)

points | bars

Initial plot with temporal dt on the x-axis
image

Empty bar chart/histogram when I select data in the scatterplot
image

Works fine with quantitative counts on the x-axis
image

Also works when dt is transformed
image

@jakevdp
Copy link
Collaborator

jakevdp commented May 11, 2018

Looks like it may be a Vega-Lite issue... I've started a discussion in vega/vega-lite#3737

@gschivley
Copy link
Author

Thanks. For issues that are possible Vega-Lite should I keep reporting them here, in both, or just there?

@jakevdp
Copy link
Collaborator

jakevdp commented May 11, 2018

It's up to you: free to just report issues here. I'm happy to echo them upstream where it's appropriate.

@jakevdp
Copy link
Collaborator

jakevdp commented May 11, 2018

From vega/vega-lite#3737, it sounds like this is due to a bug in vega-lite, and the recommended workaround is to use the timeUnit transform approach that you mentioned above.

@jakevdp jakevdp added the vega: vega-lite Requires upstream action in `vega-lite` label May 11, 2018
@sterlinm
Copy link
Contributor

I know this is a bit old, but just curious does this workaround work if you want to create the selection using fields rather than encoding?

@sterlinm
Copy link
Contributor

Ah sorry, I think I found the explanation here. Interval selections don't work for fields it seems.

@jakevdp
Copy link
Collaborator

jakevdp commented May 30, 2019

Update: still broken in Altair 3.0/Vega-Lite 3.2

@jakevdp jakevdp added the bug label May 30, 2019
@joelostblom
Copy link
Contributor

@gschivley I am going through Altair issues to find those that have been resolved and can be closed. It looks to me like this issue has been solved in the latest version of Altair so I am closing it, but please feel free to reopen and add a comment if there is something you don't think is resolved yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug vega: vega-lite Requires upstream action in `vega-lite`
Projects
None yet
Development

No branches or pull requests

4 participants