vega / vega-lite

A concise grammar of interactive graphics, built on Vega.
https://vega.github.io/vega-lite/
BSD 3-Clause "New" or "Revised" License
4.68k stars 611 forks source link

Compiling vegalite to vega introduce many undefined keys for axes #7776

Open mattijn opened 3 years ago

mattijn commented 3 years ago

In this observable notebook I present my use-case: https://observablehq.com/@mattijn/compile-vegalite-to-vega I've some simple vega-lite spec that I compile into a vega spec: vega_spec = vegalite.compile(vegalite_spec).spec

But this vega specification contains many keys with the value undefined for the axis. image

But when clicking on the dots of the vega-lite chart and click 'View Compiled Vega' I see this result for the axis: image

No keys with value undefined. Is this difference intended?

Context: this altair test is currently failing: https://github.com/ChristopherDavisUCI/altair/blob/sample417/altair/utils/tests/test_mimebundle.py#L156, since it wants vega output that is defined like this: https://github.com/ChristopherDavisUCI/altair/blob/sample417/altair/utils/tests/test_mimebundle.py#L42, but currently the compiled vega contains many keys with the value undefined.

domoritz commented 3 years ago

Undefined values when serialized as JSON remove the keys. We try to not have undefined values in the generated Vega but it looks like we missed something in axes. We can fix this.