Closed giorgi-ghviniashvili closed 3 years ago
Ideally this could take as input a vegalite spec with a facet specification, then convert it on the javascript side to a vegalite spec with only one set of axes that fakes the facets. this could be done by reading off pixel locations from the original spec that never gets shown to the user, just gets used to read off pixel coordinates and create new x/y data for the gemini-compatible spec.
There's the issue of how to label the facets---either by making the axes continuous and the labels as annotations on top of them, or as a discrete scale with the facet labels as axis labels and the x/y points made to fit in the right way.
@jhofman I think @sharlagelfand has done it on R side to fake the facets, can we ask her to either show the code or describe what exact was done?
sure, although i think the way this is done in R is very R-specific, by reading off of a ggplot object.
i imagine this would be different in vegalite. my best guess would be this, unless there's a cleaner way: create an invisible div, use vegalite to render the faceted spec there. then select that div and pull out the x/y coordinates of all of the points that were rendered. make a new dataset out of that, and a new non-faceted spec containing that dataset. then render that using gemini.
make sense?
Yes, that makes sense.
Couple of issues:
vegaEmbed("#vis", spec, {renderer: "svg"})
- draws on svg.
https://github.com/vega/vega-view#view_data
- interesting method
Accessing internal scale:
hey @jhofman , I managed to hack faceted view and create non faceted view.
Some notes:
@jhofman then I applied same code to colored facet and got this. Pretty impressed. I am going to add annotations and then try to animation it with gemini!
Perfect! added labels as well with some extra padding around groups:
Used same technique from @sharlagelfand 's comment in #25 .
Hi @jhofman , here is the original work-degree animation with fake facets: https://rawcdn.githack.com/jhofman/datamations/gio/d3/sandbox/vega-gemini/work-degree/facets.html?version=0.2
Even with gemini recommendations it has some weird errors... Or does not correctly show axis on animation while drawing with vega is ok with axis and stuff.
Just linking to #33. Next up is to debug the axis annotations not showing up for the last two frames of the work-degree animation (distribution and mean).
Also linking this to #23, see there for more.
@giorgi-ghviniashvili: noticed that when we have a nominal or ordinal variable on the x axis with fake facets, the x axis isn't "centered".
so for instance, with the penguins data and sex on the x axis, the x axis goes from 0 to 3, and since the x data goes from 1 to 3, everything looks like it's shifted to the right a bit in the facet instead of centered in the facet.
can you adjust this so that things are centered horizontally within the facets? for instance in this case, maybe the x axis goes from 0.5 to 3.5?
@jhofman that's the new issue we talked about