-
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
Add support for the pipe operator #21
Conversation
In the devl branch I am currently moving away from VegaLite specs built by adding pieces (with Currently in devl, I am using nested function calls with a durl = "https://raw.githubusercontent.com/vega/new-editor/master/data/movies.json"
plot(_data(url=durl),
mark="circle",
_encoding(_x(_bin(maxbins=10), field="IMDB_Rating", typ="quantitative"),
_y(_bin(maxbins=10), field="Rotten_Tomatoes_Rating", typ="quantitative"),
_color(field="Rotten_Tomatoes_Rating", typ="quantitative"),
_size(aggregate="count", typ="quantitative")),
width=300, height=300) One advantage of keeping a syntax that maps directly to the JSON spec is that I can auto-generate all functions and associated docs from the JSON schema file of the VegaLite project. This enables an almost instant synchronization with the project at very little cost (changing the pkg.build to point to the new versions and checking that the auto-generation still passes and that docs are not mangled). Do you think that keeping the additive syntax (with |
Hm, interesting... I kind of like the composition via some operator at the root level, especially given the ggplot precedent. It kind of allows for a simple building up of figures. I think the idea that one can pipe something into a plot would work with the new design in any case, though. The code might look like: load("data.csv") |>
plot(
mark="circle",
_encoding(_x(_bin(maxbins=10), field="IMDB_Rating", typ="quantitative"),
_y(_bin(maxbins=10), field="Rotten_Tomatoes_Rating", typ="quantitative"),
_color(field="Rotten_Tomatoes_Rating", typ="quantitative"),
_size(aggregate="count", typ="quantitative")),
width=300, height=300) I completely understand the desire to match the upstream schema automatically, but I have to say that the API here seems to look quite a bit less attractive relative to what is on To be honest, my first reaction to the original design on Maybe one could have the automatically generated stuff as the bottom layer, but then provide another user facing API on top of that that looks more like the old API? I'm not sure that would really buy us much, but maybe worth a thought? |
3 similar comments
Those are good points and I'll try to come up with something that preserves the spirit of the old syntax. Everywhere strings are valid, symbols can be provided too. There are all translated to JSON the same. |
@fredo-dedup I'm now done integrating my whole IterableTables.jl and Query.jl framework with FileIO.jl and a general pipe syntax. If we could merge this here, it would enable some really nice flows: load("data.csv") |>
@query(i, begin
@group i by i.children into g
@select {children = g.children, age = mean(g..age)}
end |>
data_values() |>
mark_bar() |>
encoding_x_quant(:x; bin=Dict(:maxbins=>20), axis=Dict(:title=>"values")) |>
encoding_y_quant(:*, aggregate="count", axis=Dict(:title=>"number of draws")) |>
save("output.pdf") There is support for quite a wide range of file formats, both on the load and the save front. Note in particular that I managed to reuse the It would be great if I could show-case all of this in my juliacon talk on Query.jl. Do you think there is a chance that you could merge this PR and then tag a version based on the current |
Cool, thanks, much appreciated!! |
fix within check
This enables the following syntax:
In itself probably not a huge improvement over the existing
+
(althoughggvis
also uses pipes instead of+
, so there is some precedence).But I hope to enable a dplyr like interface for Query.jl, and at that point it might make for a nice overall UI experience, i.e. one could pipe all the way from say a csv load, through some query manipulations into a plot.