@@ -2,27 +2,40 @@ import type {ChannelReducers} from "../channel.js";
2
2
import type { Reducer } from "../reducer.js" ;
3
3
import type { Transformed } from "./basic.js" ;
4
4
5
+ /** Options for outputs of the group transform. */
5
6
export interface GroupOutputOptions {
6
7
/**
7
- * The data reducer ; defaults to the subset of data corresponding to the
8
- * group in input order.
8
+ * How to reduce data ; defaults to the identity reducer, outputting the array
9
+ * of data for each group in input order.
9
10
*/
10
11
data ?: Reducer | null ;
12
+
11
13
/**
12
- * The filter reducer, defaults to a check on empty groups. Use null to return
13
- * all groups, for example to impute sum=0 for a line chart.
14
+ * How to filter groups: if the reducer emits a falsey value, the group will
15
+ * be dropped; by default, empty groups are dropped. Use null to disable
16
+ * filtering and return all groups, for example to impute missing zeroes when
17
+ * summing values for a line chart.
14
18
*/
15
19
filter ?: Reducer | null ;
20
+
16
21
/**
17
- * The order in which the groups are generated.
22
+ * How to order groups. By default, groups are returned in ascending natural
23
+ * order along *x*, *y*, and *z* (or *fill* or *stroke*). Group order affects
24
+ * draw order of overlapping marks, and may be useful in conjunction with the
25
+ * stack transform which defaults to input order. For example to place the
26
+ * smallest group within each stack on the baseline:
27
+ *
28
+ * ```js
29
+ * Plot.groupX({y: "count", sort: "count"}, {fill: "sex", x: "sport"})
30
+ * ```
18
31
*/
19
32
sort ?: Reducer | null ;
20
- /**
21
- * Reverse the order in which the groups are generated.
22
- */
33
+
34
+ /** If true, reverse the order of generated groups; defaults to false. */
23
35
reverse ?: boolean ;
24
36
}
25
37
38
+ /** How to reduce grouped channel values. */
26
39
export type GroupOutputs = ChannelReducers & GroupOutputOptions ;
27
40
28
41
/**
0 commit comments