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

Inject empty data at top level for easier datum encodings #2515

Merged
merged 1 commit into from
Nov 12, 2021

Conversation

jakevdp
Copy link
Collaborator

@jakevdp jakevdp commented Nov 9, 2021

.cc @mattijn

I think this is roughly what you had in mind in the previous discussion (#2513 (comment)). We may want a more sophisticated version of this rather than always adding empty data at the top level.

@ChristopherDavisUCI
Copy link
Contributor

ChristopherDavisUCI commented Nov 10, 2021

I saw in the Vega-Lite schema that "type": "null" is an allowable option for the data property. Is there a standard way to use that in Altair? For me writing something like alt.Chart(None) is just as nice (or maybe even nicer since it's more explicit) as writing alt.Chart() if we want to specify empty data.

@jakevdp
Copy link
Collaborator Author

jakevdp commented Nov 10, 2021

Interesting - where do you see that {"type": null} is a valid option for data? When I look at the v4 schema, I only see URLData (which requires "url"), NamedData (which requires "name"), and InlineData (which requires "values"). Are you talking about the v5 schema?

@ChristopherDavisUCI
Copy link
Contributor

Maybe you're one level deeper in the schema than I am? I see "type": "null" under:
TopLevelUnitSpec->properties->data.

@jakevdp
Copy link
Collaborator Author

jakevdp commented Nov 10, 2021

Ah, yeah I see. I think the meaning of data=None is different than what we want here, though:

"description": "An object describing the data source. Set to `null` to ignore the parent's data source. If no data is set, it is derived from the parent."

So data=Undefined (the default in alt.Chart()) means to use the parent's data, if any, and data=None (alt.Chart(None)) means ignore parent data and act as if there's no data set for this subchart.

For showing datum encodings, we actually do want data to be defined, but we want a single row with no columns, i.e. data={'values': [{}]}.

@ChristopherDavisUCI
Copy link
Contributor

I see! I often find those schema descriptions difficult to parse, so I've often gotten in the habit of not even looking at them.

If there's anything you'd like me to try related to this empty encoding, just let me know (I couldn't tell if there was more to be done or not). But for now I'll go back to thinking about version 5.

@jakevdp jakevdp force-pushed the datum-chart branch 2 times, most recently from 8199f6c to 136f47f Compare November 12, 2021 03:49
@jakevdp jakevdp merged commit ea35b61 into vega:master Nov 12, 2021
@jakevdp jakevdp deleted the datum-chart branch November 12, 2021 04:34
@mattijn
Copy link
Contributor

mattijn commented Nov 12, 2021

I played a bit with this; I think it works good.

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.

3 participants