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

.interactive only working with certain data types. #933

Closed
Alcampopiano opened this issue Jun 11, 2018 · 8 comments
Closed

.interactive only working with certain data types. #933

Alcampopiano opened this issue Jun 11, 2018 · 8 comments

Comments

@Alcampopiano
Copy link

Alcampopiano commented Jun 11, 2018

Hi Altair users,

Is there a reason why adding ".interactive" does not work for the following example? I'm unable to pan or zoom. However if I use a temporal data type for the dates, then it works (although the rect marks now go on forever in the past).

df=pd.DataFrame({'days_between': ['2017-01-01', '2017-01-02', '2017-01-03'], 'variable': ['person_1', 'person_2', 'person_3'], 'value': [1,2,3]})

alt.Chart(df).mark_rect().encode(
    x='days_between:O',
    y='variable:N',
    color=alt.Color('value:Q', scale=alt.Scale(range=['green','yellow','red']))).properties(width=300, height=100).interactive()

visualization 3

With a temporal data type:

...
 x='days_between:T',
...

visualization 2

Any help is appreciated.

Al

@Casyfill
Copy link

same issue - .interactive() does not work with geoshapes for me:

alt.Chart(boundaries).project(type="mercator",center=[-73.99,40.72]
).properties(width=500,height=300).mark_geoshape(fill='lightgrey').encode().interactive()

results in

Javascript Error: Expression parse error: " ? {unit: \"\", intervals: []} : null". This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.

@Alcampopiano
Copy link
Author

@Casyfill I don't think this is the same issue as mine since I am not getting an error.

@jakevdp
Copy link
Collaborator

jakevdp commented Jun 11, 2018

This is a known issue; see #679 and vega/vega-lite#3306

@jakevdp jakevdp closed this as completed Jun 11, 2018
@Alcampopiano
Copy link
Author

Jake, since my issue is not related to geo, should it be closed?

@jakevdp
Copy link
Collaborator

jakevdp commented Jun 11, 2018

Sorry, I thought it was related to geo.

Reading more closely, it looks like your issue is that interactive() does not work on ordinal/nominal scales, is that right? If so, that's by design, so perhaps it just needs to be better documented?

@Alcampopiano
Copy link
Author

Yes, that was the issue. Thanks for clarifying.

@JarnoRFB
Copy link
Contributor

Would there be any way to make this work? As I can see vega-lite achieves pan and zoom by a grid selection https://vega.github.io/vega-lite/examples/selection_translate_scatterplot_drag.html. Is this only applicable to quantitative variables? I am trying to make a correlation matrix with many variables and being able to zoom in would be very helpful.

@jakevdp
Copy link
Collaborator

jakevdp commented Nov 26, 2018

Vega-Lite achieves pan/zoom behavior by binding an interval selection to "scales". This is precisely what calling chart.interactive() does in Altair.

The issue here is that interval selections bound to scales for non-quantitative encodings do not have any effect in Vega-lite, and from the linked issues this appears to be by design. So no, there currently is no way to make this work.

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

No branches or pull requests

4 participants