Closed kanitw closed 5 years ago
Seems like it mainly looks messy because you give the legend a fixed height. If you adapt the legend to the height of the chart, it should be ok, especially for continous legends. It might not be feasible for ordinal legends with many items.
As a side note, if you continue to use Vega 3 nothing changes but charts look different in Vega 4.
Seems like it mainly looks messy because you give the legend a fixed height. If you adapt the legend to the height of the chart, it should be ok, especially for continous legends. It might not be feasible for ordinal legends with many items.
I like this suggestion. We could try to see if we can set the legend height only for continuous legends.
You have to keep the height of the title in mind, though. I filed an issue about legend titles in https://github.com/vega/vega/issues/1279
Ther is an issue if we have multiple legends as they take up a lot of vertical space. See https://github.com/vega/vega-lite/issues/3873
We could count the number of legends and divide the space equally. Or automatically change to horizontal legends if there is more than one scale. I think I prefer the latter.
I think the new default is fine but we might want to a) automatically set the gradient length b) change the default direction when there are more than one legend.
Vertical is probably good default in Vega because people tend to customize things more in Vega.
However, in Vega-Lite, there are so many cases where this can be broken.
I'd say that horizontal is a more conservative choice, taking Tableau as inspiration.
For example, vertical legend here leads to so much wasted space and imbalance for aggregated field (which happens so often in VL, but you won't have similar title in Vega.)
Way less space wasted
I think the vertical one is better for the map examples though. But if our optimization goal is to minimize layout imbalance and % of wasted space, then I think horizontal fits our optimization goals in VL better.
b) change the default direction when there are more than one legend.
So far, we actually generally avoid a design where one focused change affects another change. Thus, I'd argue that this design is bad. (Adding one encoding channel should not change the legend of an existing channel. The encoding should be orthogonal.)
a) automatically set the gradient length
This might be okay. But how would you set it in such as way that works for multiple legends, esp. if one is continuous and another is discrete?
Since changing the orientation is also easy enough, we could make horizontal the default, but customize our map examples to use "vertical"
.
Let's outline all different cases
1a) with reasonable height
concat_marginal_histograms
rect_binned_heatmap.svg
1b) with a bit small plots
rect_heatmap
rect_heatmap_weather
rect_lasagna_future
It's unclear to me why binned color legend should look different from quantize scale's legend
geo_choropleth
geo_repeat
line_quarter_legend
-- both of these seem wrong? -- quarter should be discrete
point_dot_timeunit_color
(This might be the case where horizontal makes more sense as it is temporal?
1) It seems liked the default legend orient is changed when we upgraded to Vega 4 rc -- not sure if this is simply due to Vega 4's changed default?
Since we didn't have a check to always re-compile examples until recently: https://github.com/vega/vega-lite/commit/cba6f359128792b90ca66fe04d86f9b36bfaa5d0. This change slipped through our releases.
2) This leads to some better orient
But this also leads to so many examples that has very imbalanced layout.
I think horizontal is still a better default since it looks less worse in many general cases. For example, even when the plot is tall enough but the legend's field has long title it still looks imbalanced.
Plus, this will be more inline with previous behavior prior to 2.5.