@@ -4,6 +4,9 @@ import type { TableFeatures } from '../types/TableFeatures'
4
4
import type { Row } from '../types/Row'
5
5
import type { AggregationFn } from '../features/column-grouping/ColumnGrouping.types'
6
6
7
+ /**
8
+ * Aggregation function for summing up the values of a column.
9
+ */
7
10
export const aggregationFn_sum : AggregationFn < any , any > = <
8
11
TFeatures extends TableFeatures ,
9
12
TData extends RowData ,
@@ -20,6 +23,9 @@ export const aggregationFn_sum: AggregationFn<any, any> = <
20
23
} , 0 )
21
24
}
22
25
26
+ /**
27
+ * Aggregation function for finding the minimum value of a column.
28
+ */
23
29
export const aggregationFn_min : AggregationFn < any , any > = <
24
30
TFeatures extends TableFeatures ,
25
31
TData extends RowData ,
@@ -44,6 +50,9 @@ export const aggregationFn_min: AggregationFn<any, any> = <
44
50
return minValue
45
51
}
46
52
53
+ /**
54
+ * Aggregation function for finding the maximum value of a column.
55
+ */
47
56
export const aggregationFn_max : AggregationFn < any , any > = <
48
57
TFeatures extends TableFeatures ,
49
58
TData extends RowData ,
@@ -67,6 +76,9 @@ export const aggregationFn_max: AggregationFn<any, any> = <
67
76
return maxValue
68
77
}
69
78
79
+ /**
80
+ * Aggregation function for finding the extent (min and max) of a column.
81
+ */
70
82
export const aggregationFn_extent : AggregationFn < any , any > = <
71
83
TFeatures extends TableFeatures ,
72
84
TData extends RowData ,
@@ -93,6 +105,9 @@ export const aggregationFn_extent: AggregationFn<any, any> = <
93
105
return [ minValue , maxValue ]
94
106
}
95
107
108
+ /**
109
+ * Aggregation function for finding the mean (average) of a column.
110
+ */
96
111
export const aggregationFn_mean : AggregationFn < any , any > = <
97
112
TFeatures extends TableFeatures ,
98
113
TData extends RowData ,
@@ -115,6 +130,9 @@ export const aggregationFn_mean: AggregationFn<any, any> = <
115
130
return
116
131
}
117
132
133
+ /**
134
+ * Aggregation function for finding the median value of a column.
135
+ */
118
136
export const aggregationFn_median : AggregationFn < any , any > = <
119
137
TFeatures extends TableFeatures ,
120
138
TData extends RowData ,
@@ -139,6 +157,9 @@ export const aggregationFn_median: AggregationFn<any, any> = <
139
157
return values . length % 2 !== 0 ? nums [ mid ] : ( nums [ mid - 1 ] ! + nums [ mid ] ! ) / 2
140
158
}
141
159
160
+ /**
161
+ * Aggregation function for finding the unique values of a column.
162
+ */
142
163
export const aggregationFn_unique : AggregationFn < any , any > = <
143
164
TFeatures extends TableFeatures ,
144
165
TData extends RowData ,
@@ -149,6 +170,9 @@ export const aggregationFn_unique: AggregationFn<any, any> = <
149
170
return Array . from ( new Set ( leafRows . map ( ( d ) => d . getValue ( columnId ) ) ) . values ( ) )
150
171
}
151
172
173
+ /**
174
+ * Aggregation function for finding the count of unique values of a column.
175
+ */
152
176
export const aggregationFn_uniqueCount : AggregationFn < any , any > = <
153
177
TFeatures extends TableFeatures ,
154
178
TData extends RowData ,
@@ -159,6 +183,9 @@ export const aggregationFn_uniqueCount: AggregationFn<any, any> = <
159
183
return new Set ( leafRows . map ( ( d ) => d . getValue ( columnId ) ) ) . size
160
184
}
161
185
186
+ /**
187
+ * Aggregation function for counting the number of rows in a column.
188
+ */
162
189
export const aggregationFn_count : AggregationFn < any , any > = <
163
190
TFeatures extends TableFeatures ,
164
191
TData extends RowData ,
0 commit comments