-
Notifications
You must be signed in to change notification settings - Fork 796
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
Using field predicates in conditions #1140
Comments
This is a bug – we need to update the list of recognized predicates here: https://github.com/altair-viz/altair/blob/master/altair/vegalite/v2/api.py#L334-L336 |
Long-term, the best fix for this would be to have schemapi auto-generate the class hierarchy implied within the vega-lite schema (so all of these predicate classes would be derived from the |
Got it, thanks! I agree that deriving each predicate class from To address this problem in the short-term, I've submitted a PR (#1143) which adds all of the field predicates listed here to I have two related questions:
(Strangely enough, these errors don't seem to manifest when running Altair just in a normal Python console. Not sure if this is a problem just with the interface with Jupyter Notebook.) |
I think the javascript error is probably due to you having an older version of vega-lite in your jupyter notebook extension. What version of the Python |
Regarding valid options for each... the The |
These definitions probably changed in one of the vega-lite updates along the way, and we forgot to update the list within the alt.condition function. |
Yeah,
I'm still a little confused. Since it's not included in either specification, would this mean that Thanks for all of your help with this! |
|
Got it! Ok, that makes sense. I've pushed another commit to PR #1143 that adds |
Hi -- first off, thanks for developing Altair! It's already been very useful for our work.
I've been looking into implementing conditional
size
encodings for marks in a visualization based on the value of an attribute. I figured I might do this by using aFieldEqualPredicate
inside acondition
, but every time I tried to use this predicate by itself in acondition
I got the following error:As an example of this, here's the Jupyter Notebook example code from the installation page, with the only addition being a
size
argument that results in this error. The intended behavior of thissize
argument would be making each point with apetalWidth
of 1 larger than the other points in the plot.Wrapping the
FieldEqualPredicate
inside aPredicate
makes this work, though:Is this current behavior (of field predicates being required to be wrapped inside a general
Predicate
when being used in acondition
) intentional? I can't find any explicit documentation of this requirement outside of the description of thepredicate
parameter ofaltair.condition()
(and without some knowledge of the variousPredicate
object hierarchies in Altair, it seems at first like a field predicate would be usable by itself for that parameter).If this behavior is intentional, I think it might be a good idea to update the docs to make this more clear. (As mentioned, from just looking at the
condition
(1) andFieldEqualPredicate
(1, 2) docs, it isn't immediately clear why the first code example in this issue fails.) In either case, I'd be happy to look into making a pull request to either change this (so that field predicates can be directly passed into conditions) or update the documentation about this behavior.Thanks again for Altair! :)
The text was updated successfully, but these errors were encountered: