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

fix: interval selection should gracefully fail if no valid projections #7442

Merged
merged 5 commits into from May 7, 2021

Conversation

arvind
Copy link
Member

@arvind arvind commented May 7, 2021

Partially addresses #7374. Our documentation already states that interval selections can only be projected via encodings but our types/schema did not reflect that. On top of that, this PR allows the interval selection to fail more gracefully when invalid projections are provided — we always threw a warning about invalid projections, but now the spec will render out a (static) visualization instead of throwing obscure parse errors.

@arvind arvind requested a review from a team May 7, 2021 17:38
@@ -63,15 +63,15 @@ const project: SelectionCompiler = {
};

const type = selCmpt.type;
const cfg = model.config.selection[type];
const cfg = model.config.selection[type] as PointSelectionConfig;
Copy link
Member

Choose a reason for hiding this comment

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

What is selCmpt.type here? If it's telling us the type, do we still need as PointSelectionConfig?

Copy link
Member Author

@arvind arvind May 7, 2021

Choose a reason for hiding this comment

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

selCmpt.type is either point or interval. But, now, fields is only a property on the former, and encodings is on both. So, doing the typecast here felt like the cleanest fix to me rather than adding duplicative code throughout the rest of this file for a selCmpt.type === 'point' type guard. But I'm very open to other/better suggestions :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively, I can put this typecast in at L102:

-fields = cfg.fields;
+fields = (cfg as PointSelectionConfig).fields;

Let me know if that's preferable.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's best not to assert a type when we don't know it yet. I changed it in 3987a99.

@arvind arvind merged commit c7be52a into master May 7, 2021
@arvind arvind deleted the as/graceful-interval-fail branch May 7, 2021 19:57
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.

None yet

2 participants