You need to use the Group data method (
https://developers.google.com/chart/interactive/docs/reference#google_visualization_data_group
): 

// create a DataTable with data from the 4th column grouped by the second 
column 
​var table2 = google.visualization.data.Group(table1, [1], [{
    column: 3,
    aggregation: google.visualization.data.sum,
    type: 'number'
}]);​ 

On Thursday, April 19, 2012 1:57:56 PM UTC-4, research800 wrote:
>
> I'm using arrayToDataTable to convert set of rows & columns to Table 
> format. 
> I need to build a pie chart using two columns of the table but pie 
> chart should be a after performing an aggregation function on the rows 
> of the "table". 
>
> Ex: Table1 
>         var data = google.visualization.arrayToDataTable([ 
>           ['YEAR','Country','State','Population'], 
>           ['2011','USA','CA',2.5], 
>           ['2011','USA','NY',3.4], 
>           ['2011','USA','PA',1.2], 
>           ['2011','CANADA','ONTARIO',0.4], 
>           ['2011','CANADA','QUEBEC',0.2], 
>         ]); 
>
> I want pie chart to be drawn for Country & Population using this data 
> (Table2): 
> Country, Population 
> USA, 7.1 
> CANADA, 0.6 
>
> Could someone explain how to create Table2 from Table1 dynamically for 
> the pie chart? 
>

-- 
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/-/WyXjbYjz7mgJ.
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