Skip to content
rondale-sc edited this page Apr 11, 2012 · 1 revision

You can summarize by adding the attribute summarizable to the field on init.

{name: 'last_name',   type: 'string',   filterable: true, summarizable: 'count' }

There are a few built in functions that can be used on a summarizable field ('sum', 'avg', 'count'). If you would like to define your own simply pass an anonymous function in the field declaration. The functions will be applied to each cell in the cvs that matches the filter criteria.

For example,

If you were to filter by last_name='Jackson' and set summarizable to 'count' it would give you a count of 3 when you called pivot.results()[0].last_name_count. The reason for the empty string is because no label fields were set. Each combination of labels has its own object in results(an array of objects) that corresponds to the summarized values.

Clone this wiki locally