-
Notifications
You must be signed in to change notification settings - Fork 39
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
WIP Macro syntax #70
Merged
Merged
WIP Macro syntax #70
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I played around with a
@vlplot
macro today. I kind of like it, I have to say :) I translated a whole bunch of specs from the vega-lite examples, you can see them here and here. The pattern is that I first plot the JSON version, and then translate the figure into the@vlplot
syntax below.I guess the key aspect of this is that everything mimics the JSON really closely. Essentially one just has to remove a couple of
"
, and replace:
with=
, and otherwise it is pretty much the same syntax. So I think that would have enormous benefits in terms of documentation etc....I also added a bunch of shortcuts. In particular:
enc
instead ofencoding
.sum(field):q
.x={"field:q",axis=nothing}
. The major benefit over a standard named tuple is that here we can have a positional thing ("field:q"
) and a keyword thing.The layered etc. part is not great yet. Here is what I have so far:
p1 + p2
will add alayer
element top1
and putp2
into that. I think that works fairly well.hcat
andvcat
thing again, but not so sure about that...I think this strategy has two things going for it: 1) for simple plots, everything ends up pretty concise (
data |> @vlplot(:point,enc={x=:foo,y=:bar})
I think is pretty good), 2) it is close to the JSON.What do you think? I'll also keep playing with your idea from #69 just to compare.