sort groups - #414
sort groups#414Fil wants to merge 3 commits into
Conversation
…erence is when the groups are stacked, and the stacking order can be made explicit related: #388
…ults to "ascending". related to #388
|
90% obsolete after #442 ; but not sorting groups is probably still a good idea. And sorting by count or input may still be useful for facet ordering. |
|
Note that #332 also takes care of facet sorting (by count, by input, or by value). |
|
There’s a lot of overlap here with the new sort and filter options for bin and group #495. But related to #435, we don’t pass the key(s) to the group reducer, so it’s not currently possible to implement the default natural ordering of groups and hence there’s a separate internal sorting that happens prior to the user-specified sort reducer. But I think we can make it work… |
|
Removing the sort here also affects the bin transform, since the bin transform groups internally, too (e.g., on z). So this is extra tricky: maybe the sort reducer would also need to be passed the group keys in addition to the bin extents. |
Don't sort the groups in
Plot.group(); the only case where it makes a difference is when the groups are stacked, and the stacking order can be made explicit (see test: penguins-species-island).Ordinal scales now accept a sort option, which can be:
"ascending": default, sorts in ascending order with undefined firstinput): sort in input order"count": sort by the number of times each ordinal value is present in the marks.Note: when using Plot.barY the "count" is equal to 1 for each bar—it is not the number of times each value is present in the data. However
{sort: "count"}works well to sort facets, or an ordinal scale for a Plot.dot chart. See the discussion in #388 for more details.The build and a few examples are available at https://observablehq.com/d/d797c5a9572385bd