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
How to encode the Trellis Scatter Plot example #5
Comments
Thanks for raising this. The example you give is what I think the Vega-Lite team call a wrapped facet, which then gets translated into a spec that uses the facet operator pattern. In elm-vegalite, I would normally just code with the facet operator pattern directly: facetTwoCols : Spec
facetTwoCols =
let
data =
dataFromUrl "https://vega.github.io/vega-lite/data/movies.json"
enc =
encoding
<< position X [ pName "Worldwide_Gross", pMType Quantitative ]
<< position Y [ pName "US_DVD_Sales", pMType Quantitative ]
in
toVegaLite
[ data []
, columns (Just 2)
, facetFlow [ fName "MPAA_Rating", fMType Ordinal ]
, specification (asSpec [ enc [], point [] ])
] (As an aside, none of the wrapped facet examples from the Vega-Lite documentation pages are rendered correctly in Safari although they do render in Chrome.) To me, the facet operator patterns feels neater in that it separates the specification for each faceted plot from the faceting specification. The question is, how useful/important would it be for elm-vegalite and hvega to support the wrapped facet pattern directly? |
Could create a enc =
encoding
<< position X [ pName "Worldwide_Gross", pMType Quantitative ]
<< position Y [ pName "US_DVD_Sales", pMType Quantitative ]
<< wrappedFacet [fName "MPAA_Rating", fMType Ordinal]
What do you think? |
I still don't have a feel for the full Vega-Lite schema/capabilities, so I am wary of suggesting API changes that I don't really understand! For the examples I am comparing the JSON output of hvega to that given on the example page, which is where I noticed the problem (essentially your first row in the table above), but as you said it is more important that the functionality be available, rather than a "bit-identical" mapping to the examples. |
Let's close it for now as there doesn't appear to be a compelling reason to introduce a wrapped facet function. |
Apologies if I'm missing something obvious (I am using hvega rather than your module, so it could well be all my own fault ...), but I can't see how to encode the https://vega.github.io/vega-lite/examples/trellis_scatter.html example (which has changed since I last looked at it). The JSON is
and the trouble I'm having is creating the
facet
entry in theencoding
object. I can seecolumn
androw
, butfacet
andfacetFlow
don't fit here (since they're not... -> List LabelledSpec -> List LabelledSpec
).The closest I could find is
facet3
inelm-vegalite/test-gallery/src/GalleryFacet.elm
, but that follows the "old" version of this plot (which had acolumn
field instead offacet
).The text was updated successfully, but these errors were encountered: