You can use the group function to get the sum of a column, you just likely 
need to use a modifier function on another column in the table to make all 
of the values to group by uniform.

var group = google.visualization.data.group(data, [{
    column: 0, // pick something other than a column you need summed
    type: 'number',
    modifier: function () {
        // make all values the same
        return 0;
    }
}], [{
    // you can repeat this object as many times as you like to get the sum 
of each column that you need
    column: 1, // use the index of the column to sum
    type: 'number',
    aggregation: google.visualization.data.sum
}]);

On Wednesday, November 28, 2012 11:57:22 PM UTC-5, Heena wrote:
>
> Thanks Asgallant.This was really helpful.
> Also is there any way to get the sum of an entire column. I tried using  
> google.visualization.data.sum 
> function but since it implements 'group by' function, so it did not work 
> out.
>
> On Thursday, November 29, 2012 3:33:13 AM UTC+5:30, asgallant wrote:
>
>> No, there's no way to set a property on a whole column.  You can iterate 
>> over the data set easily, though:
>>
>> for (var i = 0; i < data.getNumberOfRows(); i++) {
>>     data.setProperty(i, column, 'className', 'myClass');
>> }
>>
>> where data is your DataTable and column is the index of the column to 
>> adjust.  If you have multiple columns that need adjusting, you can stick 
>> the indices in an array, and iterate over the array inside the row loop:
>>
>> for (var i = 0; i < data.getNumberOfRows(); i++) {
>>     for (var j = 0; j < columns.length; j++) {
>>         data.setProperty(i, columns[j], 'className', 'myClass');
>>     }
>> }
>>
>> On Wednesday, November 28, 2012 2:43:14 PM UTC-5, Heena wrote:
>>>
>>> My data is dynamic , therefore I won't be sure about the number of rows 
>>> in my data table.
>>> Also data is very large,so setting property for each and every column 
>>> won't be possible..
>>> Doesn't the Api provide any possible way to format the allignment for 
>>> one complete column..?
>>> Thanks in advanced..
>>
>>

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