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

WIP Macro syntax #70

Merged
merged 13 commits into from
May 31, 2018
Merged

WIP Macro syntax #70

merged 13 commits into from
May 31, 2018

Conversation

davidanthoff
Copy link
Member

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:

  • One can write enc instead of encoding.
  • One can use the altair shortcut notation a la sum(field):q.
  • For marks and field definitions, one can write something like 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 a layer element to p1 and put p2 into that. I think that works fairly well.
  • I did do the hcat and vcat thing again, but not so sure about that...
  • I haven't really looked at faceting etc., that probably requires more thinking.

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.

@davidanthoff
Copy link
Member Author

And I've started porting stuff from the altair examples here and here.

So far I've not run into any difficulty, and in most cases I think our syntax is quite nice for these examples...

@queryverse queryverse deleted a comment from codecov-io May 18, 2018
@queryverse queryverse deleted a comment from coveralls May 18, 2018
@queryverse queryverse deleted a comment from codecov-io May 18, 2018
@queryverse queryverse deleted a comment from codecov-io May 20, 2018
@queryverse queryverse deleted a comment from codecov-io May 21, 2018
@davidanthoff davidanthoff merged commit ef3799d into queryverse:master May 31, 2018
@davidanthoff davidanthoff deleted the macro-syntax branch May 31, 2018 05:28
@davidanthoff davidanthoff mentioned this pull request May 31, 2018
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

1 participant