Re: Retrieving information from a table after a picker has altered it

29 views
Skip to first unread message

asgallant

unread,
Aug 29, 2012, 3:28:05 PM8/29/12
to google-visua...@googlegroups.com
You can use the google.visualization.data.group function to group data in your dataTable according to whatever criteria you like, and you can write your own aggregation functions to handle whatever you need to do with the data.  To get the data after it has been filtered by a control, call the #getDataTable method of the chartWrapper for the chart that is bound to the control.  Here is an example: http://jsfiddle.net/asgallant/dYqZx/ 

On Wednesday, August 29, 2012 1:21:37 PM UTC-4, Addison Chung wrote:
Alright so I'm not sure if there's an easier way to do this but this is the issue I'm dealing with right now. I have a datatable in which I want to tally up the unique values in a column. For example in this case I would want to tally up the number of males and females in the column.  http://code.google.com/apis/ajax/playground/?type=visualization#full_dashboard

I then want to display a separate pie chart with that data. I think I found a sum function that could add up numbers in a table but I couldn't find one that would tally up the unique values of strings. As such I wrote my own function to loop through and tally up the totals. However I want the pie chart to be binded to the datatable such that when the picker filters out the rows (such as moving the age up), the pie chart would change accordingly as well. Right now the pie chart I generate is based on only the values from the source of the datatable so the chart never changes when I filter out rows with the picker. My idea was instead to call the function every time a picker is selected to recalculate the tallys using the new filtered data table so that the pie chart would be redrawn every time. My question is if there's a way to get retrieve the data from the new table and pass it to my function. Or what would be even easier is to somehow bind two charts that are coming from different sources of data but right now this is the only way I could think of.

Thanks!
Reply all
Reply to author
Forward
0 new messages