plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.73k stars 1.83k forks source link

legend.grouporientation #5580

Open nicolaskruchten opened 3 years ago

nicolaskruchten commented 3 years ago

Right now, legend items in legend groups always stack vertically, and then the groups themselves are laid out per legend.orientation. We need a new legend.grouporientation attribute that will cause the items within a group to lay themselves out left-to-right.

archmoj commented 3 years ago

Case of legend.grouporientation: 'h' when legend.orientation: 'h' is out of scope of this issue. Right?

nicolaskruchten commented 3 years ago

I was sort of assuming we would support all four combinations... any reason not to?

alexcjohnson commented 3 years ago

@archmoj and I were discussing the h/h case this morning - what would it look like? Would it wrap somehow (within groups? only between groups? only within a group if it also wraps both before and after that group?) or only support a single line? Where would we put group gaps and group titles? I suppose we could think up answers to these but I suspect they'll be quite a bit more complex than the one new and two existing cases, and I'm not sure when you'd want to use it. So my inclination would be to only enable grouporientation='h' when orientation='v' for now (along with the two existing cases, which correspond to grouporientation='v' with either value of orientation, right?)

nicolaskruchten commented 3 years ago

OK, let's start with coercing grouporientation=v if orientation=h for now and revisit later.

nicolaskruchten commented 3 years ago

Clarification: legend.orientation here essentially defines the relationship between groups i.e. "v" means "groups stack vertically" and "h" means "groups are laid out horizontally and wrap". This is the current state of affairs if you assume that each trace is in its own group (which might not quiiite be right but close enough).

legend.grouporientation then will define the relationship between traces in a group which today is always "v" and we want to enable "h".

archmoj commented 3 years ago

What about renaming the attribute to something like legend.groupenter or legend.groupspace? Then we could use numbers/enums like true/false or <b> for enter and blank as well as single/multiple spaces.

archmoj commented 3 years ago

For example: groupspacing : 0 (or -1) could be used to enter new items to the group and it could be set to e.g. 24 (px) to enter the items on the same line.