Skip to content

Commit e9d00d5

Browse files
document current data{Table,Grid}.group function
for #855 awful as it is, even worse if it's not documented!
1 parent fbfd06b commit e9d00d5

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/data-grid.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Data grid is a simple widget designed to list the filtered records, providing
33
* a simple way to define how the items are displayed.
44
*
5-
* Note: Unlike other charts, the data grid chart (and data table) use the group attribute as a keying function
5+
* Note: Unlike other charts, the data grid chart (and data table) use the {@link dc.dataGrid#group group} attribute as a keying function
66
* for {@link https://github.com/mbostock/d3/wiki/Arrays#-nest nesting} the data together in groups.
77
* Do not pass in a crossfilter group as this will not work.
88
*
@@ -103,6 +103,23 @@ dc.dataGrid = function (parent, chartGroup) {
103103
return _chart._doRender();
104104
};
105105

106+
/**
107+
* Get or set the group function for the data grid. The group function takes a data row and
108+
* returns the key to specify to {@link https://github.com/d3/d3-3.x-api-reference/blob/master/Arrays.md#d3_nest d3.nest}
109+
* to split rows into groups.
110+
*
111+
* Do not pass in a crossfilter group as this will not work.
112+
* @method group
113+
* @memberof dc.dataGrid
114+
* @instance
115+
* @example
116+
* // group rows by the value of their field
117+
* chart
118+
* .group(function(d) { return d.field; })
119+
* @param {Function} groupFunction Function taking a row of data and returning the nest key.
120+
* @returns {Function|dc.dataTable}
121+
*/
122+
106123
/**
107124
* Get or set the index of the beginning slice which determines which entries get displayed by the widget.
108125
* Useful when implementing pagination.
@@ -219,7 +236,7 @@ dc.dataGrid = function (parent, chartGroup) {
219236
};
220237

221238
/**
222-
* Get or set sort order function.
239+
* Get or set sort the order function.
223240
* @method order
224241
* @memberof dc.dataGrid
225242
* @instance

src/data-table.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* The data table is a simple widget designed to list crossfilter focused data set (rows being
33
* filtered) in a good old tabular fashion.
44
*
5-
* Note: Unlike other charts, the data table (and data grid chart) use the group attribute as a
5+
* Note: Unlike other charts, the data table (and data grid chart) use the {@link dc.dataTable#group group} attribute as a
66
* keying function for {@link https://github.com/mbostock/d3/wiki/Arrays#-nest nesting} the data
77
* together in groups. Do not pass in a crossfilter group as this will not work.
88
*
@@ -202,6 +202,23 @@ dc.dataTable = function (parent, chartGroup) {
202202
return _chart._doRender();
203203
};
204204

205+
/**
206+
* Get or set the group function for the data table. The group function takes a data row and
207+
* returns the key to specify to {@link https://github.com/d3/d3-3.x-api-reference/blob/master/Arrays.md#d3_nest d3.nest}
208+
* to split rows into groups.
209+
*
210+
* Do not pass in a crossfilter group as this will not work.
211+
* @method group
212+
* @memberof dc.dataTable
213+
* @instance
214+
* @example
215+
* // group rows by the value of their field
216+
* chart
217+
* .group(function(d) { return d.field; })
218+
* @param {Function} groupFunction Function taking a row of data and returning the nest key.
219+
* @returns {Function|dc.dataTable}
220+
*/
221+
205222
/**
206223
* Get or set the table size which determines the number of rows displayed by the widget.
207224
* @method size

0 commit comments

Comments
 (0)