@@ -4,6 +4,9 @@ import type { TableFeatures } from '../types/TableFeatures'
44import type { Row } from '../types/Row'
55import type { AggregationFn } from '../features/column-grouping/ColumnGrouping.types'
66
7+ /**
8+ * Aggregation function for summing up the values of a column.
9+ */
710export const aggregationFn_sum : AggregationFn < any , any > = <
811 TFeatures extends TableFeatures ,
912 TData extends RowData ,
@@ -20,6 +23,9 @@ export const aggregationFn_sum: AggregationFn<any, any> = <
2023 } , 0 )
2124}
2225
26+ /**
27+ * Aggregation function for finding the minimum value of a column.
28+ */
2329export const aggregationFn_min : AggregationFn < any , any > = <
2430 TFeatures extends TableFeatures ,
2531 TData extends RowData ,
@@ -44,6 +50,9 @@ export const aggregationFn_min: AggregationFn<any, any> = <
4450 return minValue
4551}
4652
53+ /**
54+ * Aggregation function for finding the maximum value of a column.
55+ */
4756export const aggregationFn_max : AggregationFn < any , any > = <
4857 TFeatures extends TableFeatures ,
4958 TData extends RowData ,
@@ -67,6 +76,9 @@ export const aggregationFn_max: AggregationFn<any, any> = <
6776 return maxValue
6877}
6978
79+ /**
80+ * Aggregation function for finding the extent (min and max) of a column.
81+ */
7082export const aggregationFn_extent : AggregationFn < any , any > = <
7183 TFeatures extends TableFeatures ,
7284 TData extends RowData ,
@@ -93,6 +105,9 @@ export const aggregationFn_extent: AggregationFn<any, any> = <
93105 return [ minValue , maxValue ]
94106}
95107
108+ /**
109+ * Aggregation function for finding the mean (average) of a column.
110+ */
96111export const aggregationFn_mean : AggregationFn < any , any > = <
97112 TFeatures extends TableFeatures ,
98113 TData extends RowData ,
@@ -115,6 +130,9 @@ export const aggregationFn_mean: AggregationFn<any, any> = <
115130 return
116131}
117132
133+ /**
134+ * Aggregation function for finding the median value of a column.
135+ */
118136export const aggregationFn_median : AggregationFn < any , any > = <
119137 TFeatures extends TableFeatures ,
120138 TData extends RowData ,
@@ -139,6 +157,9 @@ export const aggregationFn_median: AggregationFn<any, any> = <
139157 return values . length % 2 !== 0 ? nums [ mid ] : ( nums [ mid - 1 ] ! + nums [ mid ] ! ) / 2
140158}
141159
160+ /**
161+ * Aggregation function for finding the unique values of a column.
162+ */
142163export const aggregationFn_unique : AggregationFn < any , any > = <
143164 TFeatures extends TableFeatures ,
144165 TData extends RowData ,
@@ -149,6 +170,9 @@ export const aggregationFn_unique: AggregationFn<any, any> = <
149170 return Array . from ( new Set ( leafRows . map ( ( d ) => d . getValue ( columnId ) ) ) . values ( ) )
150171}
151172
173+ /**
174+ * Aggregation function for finding the count of unique values of a column.
175+ */
152176export const aggregationFn_uniqueCount : AggregationFn < any , any > = <
153177 TFeatures extends TableFeatures ,
154178 TData extends RowData ,
@@ -159,6 +183,9 @@ export const aggregationFn_uniqueCount: AggregationFn<any, any> = <
159183 return new Set ( leafRows . map ( ( d ) => d . getValue ( columnId ) ) ) . size
160184}
161185
186+ /**
187+ * Aggregation function for counting the number of rows in a column.
188+ */
162189export const aggregationFn_count : AggregationFn < any , any > = <
163190 TFeatures extends TableFeatures ,
164191 TData extends RowData ,
0 commit comments