Open TomBor opened 7 years ago
I'm not seeing great specs on Vega-Lite for layer
... if we knew what are the required and allowed fields it shouldn't be too bad to implement.
Do you have any ideas for the API? That's a far more difficult question IMO.
layers
works in vega-editor, so I suppose it's not specific to future 2.0.
But I can't find any specs for layers
except in this pull request. I don't know if it help you.
It looks like layers
are an array of mark
and encoding
pairs. If so, maybe the right way to do this would be something like:
vegalite() %>%
add_data(...) %>%
add_layer(mark = mark_bar(), encoding = list(encode_x(), encode_y())) %>%
add_layer(mark = mark_point(), encoding = list(...)) %>%
...
I'm a little worried without more docs that it would be easy to make invalid JSON out of this, but I could see it being possible. Note, I'd probably have add_layer
pack any existing mark
and encoding
elements into a layer...
Another thought:
You could add a layer
property that defaults to 1
for each property that can be in a layer. Then you can have add_layer()
append to the layer list, layer_count()
tell you how many layers an object has, show_layers()
reply with the list saved to layer
. Then, to_spec
, print
, etc that evaluates it can have a check for layer_count() == 1
and basically remove the layer
list in that case and unnest it.
That'd be a pretty big change though.
https://idl.cs.washington.edu/files/2017-VegaLite-InfoVis.pdf - 3.2 View Composition Algebra
Describes layers
, hconcat
/vconcat
, and facet
but I don't see these descriptions on the Vega-Lite site, other than faceting through row
or column
channels.
Vega-lite 2.0 documentation is on line but not complete. Specifications for layers will be here : https://vega.github.io/vega-lite/docs/layer.html
It would be really great to have "layers" in vegalite as this example on stackoverflow show it. Thanks