-
Notifications
You must be signed in to change notification settings - Fork 621
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
Documentation: Add polyglot specs to example gallery ? #7758
Comments
Thank you for submitting the issue. @kanitw and I have been talking about this before. It would be lovely to have examples/docs in Vega-Lite, Altair, Vega-Lite-API and others. The question is how we best set this up and maintain it. Ideally, we would translate all examples automatically to another language. Were you thinking of implementing that or some way to manually add an example in a different language? That could also work and the community could gradually contribute examples. |
In Clojure it easily possible to translate into "EDN". This is the most common usage of vega in Clojure. So EDN could be fully automated. |
In the Clojure community, we are currently testing an other library for Vega lite, which is a bit higher level then Vega lite itself: These would be needed to be done by hand I suppose. There is some discussion here: https://clojurians.zulipchat.com/#narrow/stream/151924-data-science/topic/vega-lite.20examples.20in.20Clojure For this I would think indeed of having a specific folder somewhere on your website, in which the community could contribute over time one example after the other. This is basically the best solution, even in case of automation for EDN. Then we would create the needed files automatically in one go. |
In any case, we would be very happy about this. There seems to be agreement that the possibility of simple copy/paste into Clojure code files from the very complete examples vega-lite gallery would boost the adoption of Vega in Clojure. |
Sounds good. Do you have a proposal for a specific setup? Could you send a pr when we agree one one? We could also have a separate page similar to how Altair handles it. Notice the quick link to Altair from the menu bar of the Vega and Vega-Lite websites. |
One part of the setup could be, that we put in the folder one extra file for each sample, just with suffix ".edn", on this I could do a PR, for sure. |
I have no experience in coding websites, so the next part I could probably not do. In this script ? vega-lite/scripts/create-example-pages Line 11 in b61b13c
To generate a "tabbed view", where the current spec is the first tab, and there is a second tab called "edn", |
For "edn" it could in theory work to contribute a "script" as well, which generates the edn files from the .json specs. And this approach would not work for "hanami templates", they needed to be "done by hand by the Clojure community" over time. |
I have no experience in Javascript and Typescript neither. |
I think this "approach" so:
would scale for other languages. Main drawback, is that any change in the examples (an addition of an example specifically), need to trigger some work by the "language community" to add the example in each of the languages. |
I don't think that the number of potential languages could be a problem over time. This approach could be proposed as well to the "R community", same for python, Altair |
But maybe this is even the most useful arrangement, to be able to see Json Spec and EDN together. |
I think tabs make sense. I've seen a similar pattern on other documentation websites. The style and setup needs some work, though. It would definitely be great if we could avoid another dependency or at least have a clean automatic process for generating everything (maybe even in gh actions). I don't have the cycles to spend much time on this right now as I have to work on other things that keep the lights on. |
Clojure dependencies could be avoided by adding the "edn" files into the right place. site/_includes/example.html |
For the "hanami" specs, which would be contributed over time, my proposal would be to:
The same could be done for "Altair" and "R", once the community starts to create the examples. |
This would result in a bit more work for new contributors of new examples. But "forgetting" those, would make the build of the site fail, so it would be easy to spot. |
I think we should only show tabs when there are examples. Otherwise, the website will be incomplete and cause frustration. Not having a tab is a good indicator. I would expect a proposal pull request to have examples for Altair, JS API, R, Closure, and also have docs for how to add examples in the various languages. We should also have some infrastructure for testing the examples so that we don't accidentally break things. |
I contacted the people in vegawidget (R) and altair, but I am no sure, if I can bring them on board. |
The testing infrastructure seems to be a lot of work. I will think about it. |
I made an draft PR here: #7774 |
Thanks for considering this @domoritz! This would be super helpful for us. Just confirming here that for the Clojure community we have a bunch of different tools that use Vega(-Lite), and often each can be used in different ways (APIs for static compilation, live browser views via a repl, embedding in more complex documents, etc). So really focusing on the type of data representation (JSON, EDN, etc) makes the most sense for us. However, if there's already testing infrastructure for the JSON examples, I think it would suffice to simply test that the EDN examples translate back to the equivalent JSON, since all of our libraries more or less do that, and then pass the JSON off to the Vega libs running on a JS environment. Does this seem reasonable to you? I agree that it would be ideal to have GH actions for simple data translations that can be performed, like JSON -> EDN. Presumably we could also do JSON -> R list representations (al. a the vegawidget API), though this may be trickier, since R list data doesn't (easily) print in a way that can be evaluated as literals, as with Clojure/EDN or JS/JSON (may require some code that manually traverses the nested list structures and prints out Thanks again! |
Looks like > spec <- list(
description="An mtcards example",
data = list(),
mark = "point",
encoding = list(
x = list(field = "wt", type="quantitative"),
y = list(field="mpg", type="quantitative"),
color = list(field="cyl", type="nominal")))
> dput(spec)
list(description = "An mtcards example", data = list(), mark = "point",
encoding = list(x = list(field = "wt", type = "quantitative"),
y = list(field = "mpg", type = "quantitative"), color = list(
field = "cyl", type = "nominal"))) Probably not the end of the world to see multiple list entries per line when there has to be a split, but I wouldn't expect to see a single list entry split across multiple lines when it could fall on a single line following (i.e. |
Yes, that makes sense. |
FYI , I started as well 2 discussions here: |
Looks like the pieces do already exist to do this automatically with R; In short For the JSON -> EDN con version GH action, I think we may actually just be able to use Thanks again |
Yes EDN is automatable. So I still think that "file generation" is better then "automation during site build". but I am open to GH actions, but I never used them. My code for the "file generation" is here: |
(That's why I used pugget, can do maps without commas) |
Agreed; I don't mind commas too much, but I tend not to use them, so prefer copying code that leaves them out, for consistency's sake. As pointed to in the comment you linked to, |
Sorry I'm a bit late to the party here. Thanks so much for doing this. Polyglot example is a GREAT initiative and I think it would be an amazing contribution to our communities. I've been hoping we'll have this for a long time. I hope we can find a mechanism that can make this sustainable without introducing significant maintenance burdens to Vega-Lite maintainers and contributors. Here are some thoughts:
I know that this is a bit different from what Dominik suggests, but I wanna make sure that we can do this in a sustainable fashion. |
Good to see the number of languages expanding. I can see the logic of a transpiler solution for several of them as the 'other' language can map well onto its Vega-Lite JSON equivalent. I can also see the reason to avoid a PR-per-example solution which is clearly not scalable for the core team. I develop (and have done for the last 4 years), a parallel set of examples in the Elm language (and also do the same for Vega). Additionally I have a set of literate visualization examples that map closely to the vega-lite examples. For elm-vegalite at least, I don't think a transpiler solution would work. Not only because there are a few differences that aren't easily mapped computationally, but also to take advantage of the language, one might deliberately chose a different approach (e.g. perform data-shaping externally rather than as a Vega-lite transform). I wonder therefore if a slightly more flexible approach would be to have pointers on the main Vega-Lite page to other 'approved' language versions, that may in some cases be the transpiled examples, in others to approved repos or web pages. This would require a one-off and occasional periodic review (to check sites hadn't stagnated) so should be scalable. |
For the EDN format (the main one used by Clojure), for Hanami (the second format used by Clojure), automatic conversion does not work at all. Going this way (and importing the files during the build of the site (or via Github actions) is for sure possible, So the Clojure community could indeed maintain "somewhere" some files in Github, which get imported into the vega-site build in some form |
Specially if this should be done via "git hub actions" vs "bash scripts" I cannot really make a proposal.
This is fine for me. If somebody gives me some hints how this should be done, I could have a look at this. |
Maybe to add here that the Clojure community does not maintain a proper Clojure vega-lite specific example page. But in this repo the EDN specs are not present "as files", they get for the moment generated "on the fly" by some Clojure code which generates the html page: https://github.com/behrica/vl-galery/blob/e89e6d039a85493166338ce84225f87700d1a025/src/convert.clj#L46 But this repo could be "extended" easily to host the END / Hanami example specs as files. We needed probably agree on a "file system structure".
-hanami/arc_donut.vl If understand correct the full list of "examples" comes from this file: https://github.com/behrica/vega-lite/blob/polyglot-examples/site/_data/examples.json |
This would then somehow lead that a build of the vega lite site would:
|
Such a "language configuration" file (to be present in the vega-lite repo), could look like this {
"EDN" : { "git-clone-url": "https://github.com/behrica/vl-galery", "spec-directory": "specs/EDN"}
"hanami" : { "git-clone-url": "https://github.com/behrica/vl-galery", "spec-directory": "specs/hanami"}
} |
Thanks for sharing your thoughts and concerns @kanitw. I absolutely understand where you're coming from with respect to keeping the maintenance burden manageable for the Vega dev teams.
In this case, I think the best way to facilitate EDN/Clojure transpilation would be in the build phase. Assuming it's easy enough to call out to a shell command from the build phase, we can just use the binary command line tools If it's preferable not to be calling out to shell commands in the site build phase, we could either:
What seems most reasonable to the Vega team? Thanks again |
@metasoarous So the question is, if to have a common way for all non json specs, or different ways for the "automatable" formats vs "hand made formats". |
Agreed; I too would love to have Elm, Altair, etc. examples supported on the main site. However, I'm not sure of the right way to do that given the concerns @kanitw has expressed. If I understand your suggestion @behrica, it's to manually compile examples for each of these non-automatable languages/APIs in separate repositories, and import them as modules for the example site. Is this what you're thinking? This would potentially reduce the number of PRs that the Vega team has to review, since they could just update their pointers to these separate repositories once all the translations were complete, and then periodically when updates are necessary. However, this still poses a challenge as far as making sure that the examples are kept in sync, and I'm not sure how to get around this issue. What are the Vega team's thoughts on this? |
Thank you for your comment @kanitw. I absolutely agree that we need to keep the maintenance burden for the core developers low. I'm not sure a transpiler will completely eliminate that overhead, though. We will still get issues against the examples even if they are generated by a transpiler. So whether we use a transpiler or hard-coded examples (pulled in from another repo so we move issues there?) doesn't make a huge difference to me. I do prefer a transpiler, though, since it would automatically work for all examples. You have a good point, though, that we don't want to have to review pull requests so I also agree with you now to pull the examples out into another repo. I agree that we do need a fully automated process built into the site build script. That's going to take some digging into the build scripts and GitHub actions and is not something the core developers will have time for (but are of course happy to help with any advice!). |
I think this will work fine for my concern. :)
If example authoring requires manual authoring, this will pose a challenge whether the examples are in the main Vega-Lite repo or not. That's why I think we should try to do automatic conversion for wrappers/language that could use the approach..
I think we can do a bit differently. For the automatable one, we can make Vega-Lite's website build already re-run the example auto-generation script and thus we will mostly have the examples generated. For the manual ones, then we will indeed need to. |
I think you already setup the Github actions to call the website build scripts when we release a new version? |
Possibly. Adding anything to the scripts always needs some amount of fiddling and I recommend keeping it as simple as possible. |
Adding this:
which needs 2 command line tools installed: "jet" and "puget" |
This could be added as last line in "build-examples.sh" |
I restarted the PR here: #7774 |
The Clojure Data Science community is making heavy use of vega lite for plotting.
It has become the dominant technology for doing plots in Clojure.
The adaption of vega (lite) in Clojure would be eased if there would be somewhere a gallery of examples, using the Clojure syntax for the Json lite specs, as an example:
We could either create an Clojure specific example galery ourselves (reusing/copying the VL examples content of this repository),
or the official example gallery could be changed, to become "polyglot",
so showing the examples "not only in Json".
This could be done similar to some "polyglot examples of some APIs, just for illustration:
My question / proposal would be if you think it would be a good idea to change basically all the "individual example web pages", like: https://vega.github.io/vega-lite/examples/point_2d.html
to become "polyglot" and show the example not only in Json.
Clojure could be a first starting point.
The text was updated successfully, but these errors were encountered: