This is my code for the example, there's no problem with table 1 but with table 2 send an error because look for the Gender Column but there's no that column for table2.
I think Join is one possible solution, but I couldn't make it works.
function drawDashboard(){
var table1= google.visualization.arrayToDataTable([
['Gender', 'Family', 'Quantity'],
['Female', 'Tequila', 3],
['Male', 'Whisky', 5],
['Male', 'Tequila', 8]
]);
var table2 = google.visualization.data.group(table1,[1],[{
'column':2,
'aggregation': google.visualization.data.sum,
'type': 'number'
}]);
//Create a dashboard
var dashboard = new google.visualization.Dashboard(
document.getElementById('dashboard_div'));
//Create a category picker
var categoryPicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'control_div',
'options': {
'filterColumnLabel': 'Gender',
'ui': {
'labelStacking': 'vertical',
'allowTyping': false,
'allowMultiple': false
}
}
});
//Create a pie chart
var pieChart = new google.visualization.ChartWrapper({
'chartType': 'PieChart',
'containerId': 'chart_div',
'options': {
'width': 300,
'height': 300,
'pieSliceText': 'value',
'legend': true
},
'view': {'columns':[1,2]}
});
dashboard.bind(categoryPicker,pieChart);
dashboard.draw(table1); --> table1 should be replaced by a new table to use the dashboard with no problems.