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

Check field names #399

Merged
merged 6 commits into from
Oct 17, 2017
Merged

Check field names #399

merged 6 commits into from
Oct 17, 2017

Conversation

ellisonbg
Copy link
Collaborator

This adds a new _validate_spec method to the Chart object that is called during the last phase of _finalize (after shortcuts and expressions have been processed). It catches channels with missing fields and fields that are not in the dataset. It should ignore URL based datasets. Tests are included.

My only concern is how this will function for facetted and layered charts. I fear it will have the same problems that PR #185 does. But it would be a huge usability improvement that would catch the most common sources of silent failures that Altair users see.

I won't merge this until we get a chance to discuss and review...

Fixes #388

@ellisonbg ellisonbg requested a review from jakevdp October 2, 2017 22:01
@ellisonbg ellisonbg self-assigned this Oct 2, 2017
@ellisonbg ellisonbg added this to the 1.2.1 milestone Oct 2, 2017
@ellisonbg ellisonbg removed their assignment Oct 2, 2017
if field is not jst.undefined:
data_columns.add(field)
# Find columns in the visual encoding that are not in the data
missing_columns = encoded_columns - data_columns
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to manually remove "*" from missing columns

Copy link
Collaborator

Choose a reason for hiding this comment

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

... if it's present

Copy link
Collaborator

Choose a reason for hiding this comment

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

addressed now!

@jakevdp
Copy link
Collaborator

jakevdp commented Oct 6, 2017

Another thing this needs is to check data within compound charts. Unfortunately, in vega-lite 1.X, that behavior is not well-defined. I think it's better handled in 2.X.

@jakevdp
Copy link
Collaborator

jakevdp commented Oct 6, 2017

I'm not certain, but I think this change would cause a failure if you have a layered chart that contains a Chart object without its own data

@ellisonbg
Copy link
Collaborator Author

ellisonbg commented Oct 6, 2017 via email

@jakevdp
Copy link
Collaborator

jakevdp commented Oct 8, 2017

Hard to say... I worry we'd end up in a place where we raise an error on input that should work, because we're not looking in the right place for the column names.

@jakevdp
Copy link
Collaborator

jakevdp commented Oct 17, 2017

Looks good – thanks!

@jakevdp jakevdp merged commit bccbfb5 into vega:master Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants