There's no built-in functionality to handle anything like this, you'll have 
to code something that transforms the source data table into one containing 
data in the structure you want (or organize the initial data differently). 
 Perhaps something like this would do:

/*  assumes data is the dataTable object to work from
 *  groups by column 2, then meshes the original table with the group and 
adds a totals row
 */
var groupName, groupVal, rows, total = 0;
var group = google.visualization.data.group(data, [2], [{
    'column': 1,
    'aggregation': google.visualization.data.sum,
    'type': 'number'
}]);
var newData = new google.visualization.DataTable();
newData.addColumn('string', 'Location/Name');
newData.addColumn('number', 'Count');
for (i = 0; i < group.getNumberOfRows()) {
    groupName = group.getValue(i, 0);
    groupVal = group.getValue(i, 1);
    newData.addRow([groupName, groupVal]);
    total += groupVal;
    
    rows = data.getFilteredRows([{column: 2, value: groupName}]);
    for (j = 0; j < rows.length; j++) {
        newData.addRow([data.getValue(rows[i], 0), data.getValue(rows[i], 1)
]);
    }
}
newData.addRow(['Total', total]);

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/8et6Gj7VVlcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to