vega-lite: Setting only `width` when using `autosize: fit` should not use default height in compiled Vega
See the compiled Vega from this example. The height is set the default config.view.height of 200, but I’d expect this chart to only “fit” the width (since that is all I specified).
To solve this, I imagine there are two options:
- We should not apply the config’s
heightorwidthwhen using"autosize": "fit"with one of the dimensions specified. - We allow for some value of
"autosize"that specifies only to"fit"along one dimension.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (25 by maintainers)
Vega-Lite already always add default width/height if not specified (always a number for continuous and number or step for discrete) as in:
Basically, the width/height always have to come from somewhere anyway. So this issue is about how to apply the width/height (to just the axis or fit to axis + padding for label/title), not about how we get width/height.
Yes, my proposed scheme works better with width and height.
Yes. Good point that it differs a bit from https://github.com/vega/vega-lite/issues/5133#issuecomment-513447536.
But we can simplify a lot of logic by saying that
Then the logic is simply “drop the ‘x’ part of fit when
width(as defined above) is based on astepsize”.Note that we drop step when if x is continuous (as it’s invalid), so this logic should come after we drop step.
The same logic can be applied for “height” and “y”.
I think this actually simplifies the logic as compared to the comment above. Basically, we shouldn’t distinguish the width/height values whether it’s explicitly specified or derived from config.
Yes. In https://github.com/vega/vega-lite/issues/5133#issuecomment-513447536, you proposed to change VL, though, right? I am not yet convinced that we need to change the VL language.
Once that lands, you probably want to:
model.fitto be{x: boolean, y: boolean}instead ofbooleanand update their references accordingly.Thanks for volunteering to help. 😃