maybeGroup always sorts by the group key:
|
export function maybeGroup(I, X) { |
|
return X |
|
? sort( |
|
grouper(I, (i) => X[i]), |
|
first |
|
) |
|
: [[, I]]; |
|
} |
Maybe there should be a way to turn this off if you want to render the groups in input order? It’s confusing because if you set the sort option to null, you don’t get input order, you get ascending natural order, which is different from most other cases. (It makes sense with the bin transform, though.)
|
/** |
|
* How to order groups; if null (default), groups are returned in ascending |
|
* natural order along *x*, *y*, and *z* (or *fill* or *stroke*). Group order |
|
* affects draw order of overlapping marks, and may be useful with the stack |
|
* transform which defaults to input order. For example to place the smallest |
|
* group within each stack on the baseline: |
|
* |
|
* ```js |
|
* Plot.groupX({y: "count", sort: "count"}, {fill: "sex", x: "sport"}) |
|
* ``` |
|
*/ |
|
sort?: T | null; |
Ref. https://talk.observablehq.com/t/facet-custom-sort/8002/6
maybeGroup always sorts by the group key:
plot/src/transforms/group.js
Lines 229 to 236 in 98cb553
Maybe there should be a way to turn this off if you want to render the groups in input order? It’s confusing because if you set the sort option to null, you don’t get input order, you get ascending natural order, which is different from most other cases. (It makes sense with the bin transform, though.)
plot/src/transforms/group.d.ts
Lines 21 to 32 in 98cb553
Ref. https://talk.observablehq.com/t/facet-custom-sort/8002/6